:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --line: #dde4ee;
  --text: #1f2937;
  --muted: #667085;
  --blue: #2563eb;
  --blue-soft: #eaf1ff;
  --teal: #0f766e;
  --teal-soft: #e7f5f2;
  --amber: #b7791f;
  --amber-soft: #fff4dd;
  --red: #b42318;
  --red-soft: #fee4e2;
  --green: #166534;
  --green-soft: #dcfce7;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background: var(--bg);
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    "Segoe UI",
    Arial,
    sans-serif;
}

body:has(.login-layer) {
  overflow: hidden;
}

button,
input,
select,
textarea {
  max-width: 100%;
  font: inherit;
}

button {
  touch-action: manipulation;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 232px 1fr;
}

.sidebar {
  background: #111827;
  color: #ffffff;
  padding: 20px 16px;
}

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

.sidebar-close,
.mobile-menu-button,
.nav-backdrop {
  display: none;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 26px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #2dd4bf;
  color: #0f172a;
  font-weight: 800;
}

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

.brand-subtitle {
  margin-top: 4px;
  color: #aab4c5;
  font-size: 12px;
}

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

.nav-item {
  width: 100%;
  height: 42px;
  border: 0;
  border-radius: 8px;
  color: #d1d5db;
  background: transparent;
  text-align: left;
  padding: 0 14px;
  cursor: pointer;
}

.nav-subitem {
  height: 36px;
  margin-left: 12px;
  width: calc(100% - 12px);
  padding-left: 20px;
  font-size: 14px;
}

.nav-item:hover,
.nav-item.active {
  color: #ffffff;
  background: #2563eb;
}

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

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

.topbar-heading {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
}

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

.top-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.role-switch {
  height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  font-size: 13px;
}

.role-switch select {
  border: 0;
  color: var(--text);
  background: transparent;
  outline: 0;
}

.user-chip {
  height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--blue-soft);
  color: #1d4ed8;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.view-root {
  min-width: 0;
  padding: 20px 24px 28px;
}

.primary-button,
.ghost-button,
.icon-button {
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}

.primary-button {
  height: 38px;
  padding: 0 16px;
  color: #ffffff;
  background: var(--blue);
}

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

.ghost-button {
  height: 34px;
  padding: 0 12px;
  color: var(--text);
  background: #ffffff;
  border-color: var(--line);
}

.danger-button {
  color: var(--red);
  background: var(--red-soft);
  border-color: #fda29b;
}

.icon-button {
  width: 38px;
  height: 38px;
  color: var(--text);
  background: #ffffff;
  border-color: var(--line);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
}

.dashboard-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 12px;
}

.dashboard-kpi-grid.secondary {
  grid-template-columns: repeat(3, minmax(170px, 1fr));
  margin-top: 16px;
}

.kpi-card,
.panel {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.kpi-card {
  padding: 16px;
  position: relative;
  overflow: hidden;
}

.kpi-card::after {
  content: "";
  position: absolute;
  right: -26px;
  top: -30px;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
}

.kpi-card.tone-row-one {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.kpi-card.tone-row-two {
  background: #fff7ed;
  border-color: #fed7aa;
}

.kpi-label {
  color: var(--muted);
  font-size: 13px;
}

.kpi-value {
  margin-top: 10px;
  font-size: 28px;
  font-weight: 800;
}

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

.content-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
  gap: 16px;
}

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

.metric-list {
  display: grid;
  gap: 12px;
}

.metric-row {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.metric-main {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  font-size: 13px;
}

.metric-main strong {
  font-size: 20px;
}

.metric-bar {
  height: 8px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #eef2f7;
}

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

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

.status-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 12px;
}

.status-pill {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.status-pill-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

.status-pill-top strong {
  font-size: 22px;
}

.calendar-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #344054;
  font-weight: 700;
}

.calendar-selectors {
  display: inline-flex;
  gap: 6px;
}

.calendar-selectors select {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #ffffff;
  color: var(--text);
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: 8px;
  background: #eef2f7;
}

.segmented button {
  min-width: 38px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #667085;
  cursor: pointer;
}

.segmented button.active {
  background: #ffffff;
  color: var(--text);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

.calendar-board {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #f7fbff;
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.03);
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.calendar-weekdays div {
  padding: 12px 14px;
  color: #475467;
  font-weight: 700;
  font-size: 13px;
}

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

.calendar-cell {
  min-height: 124px;
  padding: 10px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}

.calendar-board.week .calendar-cell {
  min-height: 260px;
}

.calendar-cell:nth-child(7n) {
  border-right: 0;
}

.calendar-cell.muted {
  color: #98a2b3;
  background: rgba(248, 250, 252, 0.7);
}

.calendar-cell.today .calendar-date {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #ffffff;
  background: var(--blue);
}

.calendar-date {
  margin-bottom: 8px;
  color: #344054;
  font-weight: 700;
}

.calendar-events {
  display: grid;
  gap: 5px;
}

.calendar-event {
  min-width: 0;
  width: 100%;
  height: 26px;
  overflow: hidden;
  border: 0;
  border-radius: 5px;
  padding: 0 8px;
  text-align: left;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: #344054;
  cursor: pointer;
}

.calendar-event.event-active {
  background: #dff8f4;
}

.calendar-event.event-done {
  background: #e7f0ff;
}

.calendar-event.event-burst {
  background: #f3e8ff;
}

.calendar-event.event-muted {
  background: #eef2f7;
}

.calendar-more {
  color: var(--muted);
  font-size: 12px;
}

.mt {
  margin-top: 16px;
}

.mt-xs {
  margin-top: 8px;
}

.mt-sm {
  margin-top: 12px;
}

.panel {
  padding: 16px;
}

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

.panel-header.tight {
  margin-top: 4px;
}

.panel-title {
  margin: 0;
  font-size: 16px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

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

.sub-panel {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.sub-panel:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.field,
.select {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #ffffff;
}

.field {
  min-width: 220px;
}

.money-input-wrap {
  position: relative;
  width: 100%;
  min-width: 220px;
}

.money-input-wrap .money-field {
  width: 100%;
  padding-right: 38px;
}

.money-unit {
  position: absolute;
  top: 50%;
  right: 12px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
  font-size: 13px;
}

.form-item-wide {
  grid-column: 1 / -1;
}

.textarea-field {
  width: 100%;
  height: auto;
  min-height: 82px;
  padding: 10px;
  resize: vertical;
  line-height: 1.5;
}

.teacher-search {
  width: 100%;
  margin-bottom: 8px;
}

.checkbox-picker {
  max-height: 220px;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.checkbox-option {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  background: #f8fafc;
  font-size: 13px;
}

.checkbox-option.is-disabled {
  color: #94a3b8;
  background: #eef2f7;
}

.table-wrap {
  overflow: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
  font-size: 13px;
}

th {
  color: #344054;
  background: #f8fafc;
  font-weight: 700;
}

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

.row-current-pending td {
  background: #fff7e6;
}

.row-current-pending td:first-child {
  border-left: 4px solid #f59e0b;
}

.link-button {
  padding: 0;
  color: var(--blue);
  background: transparent;
  border: 0;
  cursor: pointer;
}

.danger-text {
  margin-left: 10px;
  color: var(--red);
}

.status,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

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

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

.status-after {
  color: var(--teal);
  background: var(--teal-soft);
}

.status-waiting {
  color: #1d4ed8;
  background: #dbeafe;
}

.status-burst {
  color: #6d28d9;
  background: #ede9fe;
}

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

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

.status-cancelled {
  color: #475467;
  background: #e4e7ec;
}

.status-stack {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.tag {
  color: #344054;
  background: #eef2f7;
}

.tag-return {
  color: #b42318;
  background: #fff1f0;
  border: 1px solid #fecdca;
}

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

.flow-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.flow-line span {
  padding: 8px 10px;
  border-radius: 8px;
  color: #344054;
  background: #eef2f7;
  font-size: 12px;
  font-weight: 700;
}

.flow-line span.active {
  color: #ffffff;
  background: var(--blue);
}

.flow-line span.done {
  color: var(--green);
  background: var(--green-soft);
}

.flow-line span.locked {
  color: #98a2b3;
  background: #f2f4f7;
}

.step {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.step-index {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #ffffff;
  background: var(--blue);
  font-weight: 800;
}

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

.step-desc {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

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

.list.compact {
  gap: 6px;
}

.list-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.project-log-item {
  display: grid;
  gap: 6px;
}

.project-log-content {
  color: var(--text);
  font-weight: 600;
}

.project-log-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  color: var(--muted);
  font-size: 12px;
}

.list-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-weight: 700;
}

.list-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

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

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

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(760px, 92vw);
  height: 100vh;
  height: 100dvh;
  background: #ffffff;
  box-shadow: -18px 0 40px rgba(15, 23, 42, 0.16);
  display: flex;
  flex-direction: column;
  z-index: 50;
}

.hidden {
  display: none;
}

.drawer-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.drawer-header h2 {
  margin: 0;
  font-size: 20px;
}

.drawer-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.drawer-body {
  padding: 18px 20px 28px;
  overflow: auto;
  overscroll-behavior: contain;
}

.drawer-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.detail-section {
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

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

.detail-section h3 {
  margin: 0 0 12px;
  font-size: 15px;
}

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

.form-item {
  display: grid;
  gap: 6px;
}

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

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

.form-value {
  min-height: 36px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  font-size: 13px;
}

.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.empty-small {
  padding: 18px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.progress-steps {
  display: grid;
  grid-template-columns: repeat(7, minmax(74px, 1fr));
  gap: 6px;
}

.progress-steps span {
  min-height: 34px;
  display: grid;
  place-items: center;
  padding: 6px;
  border-radius: 8px;
  color: #667085;
  background: #eef2f7;
  font-size: 12px;
  text-align: center;
}

.progress-steps span.done {
  color: #ffffff;
  background: var(--blue);
}

.progress-steps span.active {
  color: #ffffff;
  background: var(--green);
}

.channel-tree {
  display: grid;
  gap: 8px;
}

.channel-tree-node {
  margin-left: calc(var(--depth) * 24px);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-left: 5px solid #2f80ed;
  border-radius: 8px;
  background: #ffffff;
}

.channel-tone-0 {
  border-left-color: #2f80ed;
  background: #f4f8ff;
}

.channel-tone-1 {
  border-left-color: #16a34a;
  background: #f3fbf6;
}

.channel-tone-2 {
  border-left-color: #f59e0b;
  background: #fff8ec;
}

.channel-tone-3 {
  border-left-color: #14b8a6;
  background: #effcf9;
}

.channel-tone-4 {
  border-left-color: #8b5cf6;
  background: #f7f3ff;
}

.channel-tone-5 {
  border-left-color: #ef4444;
  background: #fff5f5;
}

.channel-tree-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.channel-toggle {
  width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #0f172a;
  background: #ffffff;
  font-weight: 700;
  cursor: pointer;
}

.channel-toggle.placeholder {
  visibility: hidden;
  cursor: default;
}

.channel-store-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.channel-store-list span {
  padding: 3px 8px;
  color: #475467;
  background: #f2f4f7;
  border-radius: 999px;
  font-size: 12px;
}

.login-layer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-y: auto;
  background:
    linear-gradient(rgba(17, 24, 39, 0.78), rgba(17, 24, 39, 0.78)),
    #111827;
}

.login-card {
  width: min(380px, 100%);
  display: grid;
  gap: 12px;
  padding: 28px;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.25);
}

.login-card h2 {
  margin: 0;
  font-size: 24px;
}

.login-card p {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
}

.form-error {
  min-height: 18px;
  color: var(--red);
  font-size: 13px;
  text-align: center;
}

.field-hint {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.login-mark {
  margin-bottom: 6px;
}

.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 300;
  max-width: min(720px, calc(100vw - 32px));
  padding: 14px 18px;
  border-radius: 8px;
  transform: translateX(-50%);
  color: #ffffff;
  background: #111827;
  box-shadow: var(--shadow);
  font-weight: 700;
  line-height: 1.5;
}

.toast.success {
  background: #12715b;
}

.toast.error {
  background: #b42318;
}

.form-notice {
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  color: #344054;
  background: #f8fafc;
  font-weight: 700;
  line-height: 1.5;
}

.form-notice.error {
  border-color: #fecdca;
  color: #912018;
  background: #fff1f0;
}

.form-notice.success {
  border-color: #abefc6;
  color: #05603a;
  background: #ecfdf3;
}

@media (max-width: 980px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 90;
    width: min(320px, 86vw);
    height: 100vh;
    height: 100dvh;
    padding: 16px;
    overflow-y: auto;
    overscroll-behavior: contain;
    visibility: hidden;
    transform: translateX(-100%);
    transition: transform 180ms ease, visibility 180ms ease;
  }

  .sidebar.mobile-open {
    visibility: visible;
    transform: translateX(0);
    box-shadow: 18px 0 40px rgba(15, 23, 42, 0.28);
  }

  .sidebar-head {
    align-items: center;
    margin-bottom: 18px;
  }

  .sidebar-close {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.22);
  }

  .brand {
    min-width: 0;
    margin-bottom: 0;
  }

  .nav {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .nav-item {
    min-height: 44px;
    text-align: left;
    padding: 0 14px;
  }

  .nav-subitem {
    width: calc(100% - 12px);
    min-height: 40px;
    margin-left: 12px;
    padding-left: 22px;
  }

  .nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: block;
    background: rgba(15, 23, 42, 0.45);
  }

  .nav-backdrop.hidden {
    display: none;
  }

  body.nav-open {
    overflow: hidden;
  }

  .mobile-menu-button {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
  }

  .kpi-grid,
  .dashboard-kpi-grid,
  .dashboard-kpi-grid.secondary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content-grid,
  .summary-grid {
    grid-template-columns: 1fr;
  }

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

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

  .calendar-board {
    overflow-x: auto;
  }

  .calendar-weekdays,
  .calendar-grid {
    min-width: 860px;
  }

  .progress-steps {
    grid-template-columns: repeat(2, 1fr);
  }

  .topbar {
    padding: 16px 18px;
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-heading,
  .top-actions {
    width: 100%;
  }

  .top-actions {
    justify-content: flex-start;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }

  .view-root {
    padding: 18px;
  }
}

@media (max-width: 640px) {
  body:has(.drawer:not(.hidden)) {
    overflow: hidden;
  }

  .topbar {
    gap: 12px;
    padding: 12px;
  }

  .topbar-heading {
    align-items: flex-start;
  }

  .topbar h1 {
    font-size: 19px;
  }

  .topbar p {
    margin-top: 4px;
    line-height: 1.45;
  }

  .top-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 8px;
  }

  .role-switch {
    grid-column: 1 / -1;
    width: 100%;
    height: 44px;
    justify-content: space-between;
  }

  .user-chip {
    min-width: 0;
    height: 44px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #newProjectBtn {
    grid-column: 1 / -1;
    width: 100%;
  }

  .view-root {
    padding: 12px;
  }

  .panel {
    padding: 12px;
  }

  .mt {
    margin-top: 12px;
  }

  .kpi-grid,
  .dashboard-kpi-grid,
  .dashboard-kpi-grid.secondary,
  .status-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .kpi-card,
  .status-pill {
    padding: 12px;
  }

  .kpi-value {
    margin-top: 7px;
    overflow-wrap: anywhere;
    font-size: 22px;
  }

  .status-pill-top strong {
    font-size: 19px;
  }

  .toolbar,
  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-header.tight {
    align-items: center;
    flex-direction: row;
  }

  .panel-header > .primary-button,
  .panel-header > .ghost-button,
  .toolbar > .primary-button,
  .toolbar > .ghost-button {
    width: 100%;
  }

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

  .field,
  .select {
    width: 100%;
    min-width: 0;
    height: 44px;
  }

  .primary-button,
  .ghost-button,
  .icon-button {
    min-height: 44px;
  }

  .primary-button,
  .ghost-button {
    padding-right: 14px;
    padding-left: 14px;
  }

  .table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
  }

  table {
    min-width: 0;
  }

  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    clip-path: inset(50%);
  }

  tbody {
    display: grid;
    gap: 10px;
  }

  tbody tr {
    padding: 5px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
  }

  td {
    display: grid;
    grid-template-columns: minmax(86px, 38%) minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 9px 0;
    border-bottom: 1px solid #edf1f6;
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: right;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 700;
    text-align: left;
  }

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

  td[colspan] {
    display: block;
    padding: 24px 0;
    text-align: center;
  }

  td[colspan]::before {
    content: none;
  }

  td .status-stack,
  td:last-child {
    justify-content: flex-end;
  }

  .row-current-pending {
    border-left: 4px solid #f59e0b;
  }

  .row-current-pending td:first-child {
    border-left: 0;
  }

  .link-button {
    min-height: 36px;
    padding: 4px 2px;
  }

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

  .inline-field-row {
    grid-template-columns: 1fr;
  }

  .money-input-wrap {
    min-width: 0;
  }

  .checkbox-picker {
    grid-template-columns: 1fr;
  }

  .drawer {
    width: 100vw;
    max-width: none;
  }

  .drawer-header {
    align-items: flex-start;
    padding: 14px 16px;
    padding-top: max(14px, env(safe-area-inset-top));
  }

  .drawer-header h2 {
    font-size: 18px;
  }

  .drawer-body {
    padding: 14px 14px max(24px, env(safe-area-inset-bottom));
  }

  .drawer-actions,
  .list-actions {
    flex-wrap: wrap;
  }

  .drawer-actions > button,
  form > .primary-button {
    width: 100%;
  }

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

  .step > :last-child {
    grid-column: 1 / -1;
    width: 100%;
  }

  .list-title,
  .project-log-meta {
    flex-wrap: wrap;
  }

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

  .channel-tree-node {
    margin-left: calc(var(--depth) * 10px);
  }

  .calendar-tools,
  .calendar-selectors {
    width: 100%;
  }

  .calendar-tools {
    gap: 8px;
  }

  .calendar-selectors select {
    min-width: 0;
    flex: 1;
    height: 44px;
  }

  .segmented {
    align-self: stretch;
  }

  .segmented button {
    flex: 1;
    height: 38px;
  }

  .calendar-weekdays,
  .calendar-grid {
    min-width: 700px;
  }

  .calendar-cell {
    min-height: 110px;
    padding: 8px;
  }

  .login-layer {
    padding: 14px;
  }

  .login-card {
    padding: 22px;
  }

  .login-card .field {
    min-width: 0;
  }

  .toast {
    top: max(8px, env(safe-area-inset-top));
    width: calc(100vw - 20px);
    padding: 12px 14px;
    font-size: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar {
    transition: none;
  }
}
