:root {
  color-scheme: dark;
  --bg: #0b1014;
  --rail: #101820;
  --surface: #151f28;
  --surface-2: #1b2731;
  --surface-3: #22303b;
  --ink: #eef5f3;
  --muted: #98a8ad;
  --line: rgba(172, 190, 194, 0.18);
  --line-strong: rgba(172, 190, 194, 0.32);
  --green: #21b58d;
  --green-soft: rgba(33, 181, 141, 0.16);
  --cyan: #33b8d6;
  --cyan-soft: rgba(51, 184, 214, 0.16);
  --amber: #e5a536;
  --amber-soft: rgba(229, 165, 54, 0.18);
  --red: #ee5d52;
  --red-soft: rgba(238, 93, 82, 0.18);
  --violet: #9b8cff;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.28);
  font-family:
    "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; }
html, body { overflow-x: hidden; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 72% 8%, rgba(51, 184, 214, 0.14), transparent 30%),
    linear-gradient(145deg, #091016 0%, #10161d 42%, #0d1217 100%);
}
body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.78), transparent 72%);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin-top: 0; }

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
  min-width: 0;
}
.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}
.login-card {
  display: grid;
  gap: 18px;
  width: min(440px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.025)),
    var(--surface);
  box-shadow: var(--shadow);
}
.login-brand {
  border-bottom: 0;
  padding-bottom: 0;
}
.login-card h1 {
  font-size: 34px;
}
.login-card .button {
  width: 100%;
}
.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 22px;
  height: 100vh;
  padding: 22px 16px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(16, 24, 32, 0.96), rgba(13, 20, 27, 0.92));
  box-shadow: 16px 0 50px rgba(0, 0, 0, 0.22);
}
.brand {
  display: grid;
  grid-template-columns: 44px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(33, 181, 141, 0.48);
  border-radius: 8px;
  color: #06110f;
  background: linear-gradient(135deg, #7cf0c6, var(--green));
  font-weight: 900;
}
.brand strong, .brand span { display: block; }
.brand strong {
  overflow: hidden;
  font-size: 16px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.brand span, .sidebar-card span, .sidebar-card small {
  color: var(--muted);
  font-size: 13px;
}
.nav-list { display: grid; gap: 8px; }
.nav-list button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
  text-align: left;
}
.nav-list button:hover, .nav-list button.active {
  color: var(--ink);
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.055);
}
.nav-list button span {
  width: 18px;
  color: var(--green);
  font-size: 12px;
  text-align: center;
}
.sidebar-card {
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: 12px;
  margin-top: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}
.sidebar-card::before {
  grid-row: 1 / span 3;
  width: 10px;
  height: 10px;
  margin-top: 6px;
  border-radius: 999px;
  content: "";
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(33, 181, 141, 0.5);
  animation: live-pulse 1.8s ease infinite;
}
.sidebar-card strong, .sidebar-card span, .sidebar-card small {
  display: block;
  grid-column: 2;
}
.sidebar-card strong { margin: 4px 0; font-size: 15px; }

.workspace {
  width: 100%;
  max-width: 1600px;
  min-width: 0;
  padding: 22px;
  overflow-x: hidden;
}
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}
.topbar > div:first-child {
  flex: 1 1 380px;
  min-width: 320px;
}
.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}
h1 {
  margin: 0;
  font-size: clamp(26px, 2.7vw, 42px);
  line-height: 1.1;
  letter-spacing: 0;
}
h2 { margin-bottom: 5px; font-size: 20px; }
.top-actions {
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  flex: 0 1 690px;
  max-width: 690px;
}
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(360px, 34vw);
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.055);
}
.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
}
.search-box input::placeholder, input::placeholder, textarea::placeholder { color: rgba(152, 168, 173, 0.7); }

.button, .text-button, .row-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.055);
  font-weight: 900;
}
.button.primary {
  border-color: rgba(33, 181, 141, 0.5);
  color: #06110f;
  background: linear-gradient(135deg, #7cf0c6, var(--green));
}
.button.secondary, .row-action { color: var(--ink); }
.notification-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid rgba(229, 165, 54, 0.36);
  border-radius: 8px;
  color: #ffe3a9;
  background: rgba(229, 165, 54, 0.1);
  font-weight: 900;
}
.notification-button strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 7px;
  border-radius: 999px;
  color: #06110f;
  background: #ffe3a9;
}
.row-action.danger {
  border-color: rgba(244, 114, 114, 0.34);
  color: #ffd8d8;
}
.row-action.danger:hover {
  border-color: rgba(244, 114, 114, 0.56);
  background: rgba(244, 114, 114, 0.12);
}
.button:disabled, .row-action:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}
.text-button {
  color: #c5ffe9;
  background: var(--green-soft);
}
.button.secondary:hover, .row-action:hover, .text-button:hover {
  border-color: rgba(33, 181, 141, 0.45);
  background: var(--green-soft);
}

.view { display: none; }
.view.active { display: block; }
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.metric-card, .panel, .item-card, .archive-card, .report-card, .drawer-panel, .modal-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.025)),
    var(--surface);
  box-shadow: var(--shadow);
}
.metric-card {
  position: relative;
  display: grid;
  min-height: 122px;
  padding: 15px;
  overflow: hidden;
}
.metric-card::after {
  position: absolute;
  right: -22px;
  bottom: -24px;
  width: 72px;
  height: 72px;
  border-radius: 999px;
  content: "";
  background: var(--green-soft);
}
.metric-card.warn::after { background: var(--red-soft); }
.metric-card.money::after { background: var(--amber-soft); }
.metric-card span, .metric-card small, .panel p, .meta, .item-card p, .archive-card span, .report-card span, .report-card small, .report-block span, .detail-card span {
  color: var(--muted);
}
.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(30px, 3vw, 42px);
  line-height: 1;
}
.metric-card.warn strong { color: #ffd8d4; }
.metric-card.money strong { color: #ffe3a9; }

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.78fr);
  gap: 12px;
}
.panel {
  min-width: 0;
  margin-top: 12px;
  padding: 16px;
}
.main-grid .panel { margin-top: 0; }
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.panel-head h2 { margin: 0; font-size: 18px; }
.panel-head p { margin: 5px 0 0; font-size: 13px; }
.table-head { align-items: center; }
.filter-row, .card-actions, .modal-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
input, select, textarea {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.055);
  outline: none;
}
input, textarea { padding: 9px 11px; }
select { padding: 0 30px 0 10px; }
select option {
  color: #e6f2f0;
  background: #17232b;
}
select option:checked {
  color: #06110f;
  background: #7cf0c6;
}
.role-select {
  min-width: 196px;
  min-height: 42px;
}
.inline-form {
  display: grid;
  grid-template-columns: minmax(160px, 1.1fr) 150px minmax(150px, 1fr) minmax(150px, 1fr) minmax(180px, 1fr);
  gap: 10px;
  margin: 16px 0;
}
.inline-form input, .inline-form select {
  min-width: 0;
}
.user-form-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.task-list, .bar-list, .card-grid, .archive-grid, .kanban, .report-grid, .report-summary { display: grid; gap: 10px; }
.task-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}
.date-chip {
  min-width: 68px;
  padding: 7px 8px;
  border-radius: 8px;
  color: #c5ffe9;
  background: var(--green-soft);
  text-align: center;
  font-size: 13px;
  font-weight: 900;
}
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}
.badge.high { color: #ffd8d4; background: var(--red-soft); }
.badge.medium { color: #ffe3a9; background: var(--amber-soft); }
.badge.low { color: #c5ffe9; background: var(--green-soft); }
.badge.blue { color: #c9f4ff; background: var(--cyan-soft); }
.bar-row {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr) 44px;
  gap: 12px;
  align-items: center;
}
.bar-track {
  height: 11px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--cyan));
}

.table-wrap { width: 100%; overflow-x: auto; }
table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}
th, td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}
th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}
td { font-size: 14px; }
tbody tr:hover { background: rgba(255, 255, 255, 0.035); }
.row-action { min-height: 34px; padding: 6px 10px; }

.card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.item-card, .archive-card {
  padding: 16px;
  background: rgba(255, 255, 255, 0.045);
}
.item-card h3, .archive-card h3 { margin-bottom: 8px; font-size: 18px; }
.item-card strong.amount {
  display: block;
  margin: 10px 0 4px;
  color: var(--ink);
  font-size: 26px;
}
.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.mini-tag {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.07);
  font-size: 12px;
  font-weight: 800;
}
.mini-tag.danger {
  color: #ffd8d4;
  background: var(--red-soft);
}
.kanban {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: start;
}
.kanban-column {
  min-height: 360px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}
.kanban-column h3 { font-size: 16px; }
.kanban-card {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
}
.archive-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.archive-card {
  display: grid;
  gap: 10px;
}
.archive-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.workflow-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 210px;
}
.workflow-actions .row-action {
  min-height: 30px;
  padding: 5px 8px;
}
.archive-note {
  min-height: 28px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.report-card {
  position: relative;
  min-height: 118px;
  padding: 15px;
  overflow: hidden;
}
.report-card::after {
  position: absolute;
  right: -24px;
  bottom: -28px;
  width: 78px;
  height: 78px;
  border-radius: 999px;
  content: "";
  background: rgba(51, 184, 214, 0.12);
}
.report-card strong, .report-card span, .report-card small { display: block; }
.report-card strong {
  position: relative;
  z-index: 1;
  margin: 8px 0 4px;
  font-size: clamp(26px, 2.6vw, 38px);
  line-height: 1;
}
.report-card span, .report-card small {
  position: relative;
  z-index: 1;
}
.report-summary {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 12px;
}
.channel-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.alert-panel {
  border-color: rgba(229, 165, 54, 0.24);
}
.report-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}
.report-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.report-block {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}
.report-block-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.report-block h3 {
  margin: 0;
  font-size: 16px;
}
.report-block .bar-row {
  grid-template-columns: 96px minmax(0, 1fr) 38px;
}
.mini-table-wrap {
  width: 100%;
  overflow-x: auto;
}
.mini-table {
  min-width: 100%;
}
.mini-table th, .mini-table td {
  padding: 10px 8px;
  font-size: 13px;
}
.mini-table th {
  white-space: nowrap;
}
.reminder-rule {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.status-line {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}
.status-line::before {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  content: "";
  background: var(--green);
}

.drawer {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 30;
}
.drawer.open { display: block; }
.drawer-scrim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}
.drawer-panel {
  position: absolute;
  inset: 0 0 0 auto;
  width: min(560px, 100%);
  padding: 26px;
  overflow-y: auto;
}
.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--ink);
  font-size: 20px;
  line-height: 1;
}
.close-button {
  position: absolute;
  top: 18px;
  right: 18px;
}
.detail-title { margin-right: 42px; }
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}
.detail-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}
.detail-card span {
  display: block;
  font-size: 13px;
  margin-bottom: 5px;
}

.modal {
  border: 0;
  padding: 0;
  border-radius: 10px;
  width: min(780px, calc(100% - 28px));
  background: transparent;
}
.modal::backdrop { background: rgba(0, 0, 0, 0.56); }
.modal-card { padding: 22px; }
.modal-head, .modal-actions {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}
label input, label select, label textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  color: var(--ink);
  font-weight: 500;
}
label textarea { resize: vertical; }
.modal-actions {
  justify-content: flex-end;
  margin-top: 18px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  max-width: 360px;
  padding: 12px 14px;
  border: 1px solid rgba(33, 181, 141, 0.38);
  border-radius: 8px;
  background: #101820;
  color: #c5ffe9;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: 180ms ease;
}
.toast.show { opacity: 1; transform: translateY(0); }

@keyframes live-pulse {
  70% { box-shadow: 0 0 0 10px rgba(33, 181, 141, 0); }
}

@media (max-width: 1120px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .nav-list { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .sidebar-card { display: none; }
  .metric-grid, .main-grid, .card-grid, .archive-grid, .report-grid, .report-summary, .channel-grid, .kanban { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { display: grid; }
  .top-actions { justify-content: stretch; }
  .search-box { width: min(100%, 520px); }
}

@media (max-width: 680px) {
  .workspace { padding: 16px; }
  .nav-list, .metric-grid, .main-grid, .card-grid, .archive-grid, .report-grid, .report-summary, .channel-grid, .kanban, .form-grid, .detail-grid { grid-template-columns: 1fr; }
  .search-box { width: 100%; }
  .panel-head, .task-item { display: grid; }
  .filter-row, .top-actions, .report-actions, .inline-form, .user-form-actions { display: grid; grid-template-columns: 1fr; }
  .workflow-actions { min-width: 0; }
}
