:root {
  --bg: #eef2ef;
  --surface: #fbfaf6;
  --surface-strong: #ffffff;
  --text: #1f2a27;
  --muted: #66746f;
  --line: #d8ddd6;
  --line-strong: #c4cdc6;
  --teal: #146c63;
  --teal-dark: #0e504a;
  --coral: #b75d49;
  --gold: #aa7a28;
  --green-soft: #dceee8;
  --blue-soft: #e1edf6;
  --red-soft: #f5e2dc;
  --shadow: 0 10px 28px rgba(31, 42, 39, 0.08);
  --shadow-light: 0 6px 16px rgba(31, 42, 39, 0.06);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

body {
  margin: 0;
  min-width: 320px;
}

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

button {
  cursor: pointer;
}

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

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

.app-shell.sidebar-collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
}

.sidebar {
  background: #192724;
  color: #fffdf7;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
  transition:
    opacity 160ms ease,
    padding 160ms ease;
}

.app-shell.sidebar-collapsed .sidebar {
  opacity: 0;
  padding-left: 0;
  padding-right: 0;
  pointer-events: none;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #dfbc59;
  color: #192724;
  font-weight: 800;
}

.brand h1,
.brand p,
.topbar h2,
.panel h3,
.task-section h3,
.focus-panel h3,
.dialog-body h3 {
  margin: 0;
}

.brand h1 {
  font-size: 20px;
}

.brand p {
  margin-top: 2px;
  color: rgba(255, 253, 247, 0.72);
  font-size: 13px;
}

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

.nav-tab {
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  color: #fffdf7;
  text-align: left;
  padding: 0 14px;
}

.nav-tab.active {
  background: #fbfaf6;
  color: #192724;
  box-shadow: inset 4px 0 0 #dfbc59;
}

.main-view {
  padding: 24px 28px 32px;
  max-width: 1500px;
  width: 100%;
}

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

.topbar h2 {
  font-size: 28px;
  line-height: 1.15;
}

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

.top-actions,
.button-row,
.focus-quick-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.server-status {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 0 10px;
  color: var(--muted);
  background: #f7f8f4;
  font-size: 13px;
  font-weight: 650;
}

.server-status.online {
  color: var(--teal-dark);
  border-color: #b9d6cb;
  background: #e8f2ee;
}

.server-status.error {
  color: #9a3827;
  border-color: #e2b7aa;
  background: var(--red-soft);
}

.primary-button,
.soft-button,
.ghost-button {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 14px;
  white-space: nowrap;
  font-weight: 650;
  transition:
    background-color 150ms ease,
    border-color 150ms ease,
    transform 150ms ease;
}

.primary-button {
  background: var(--teal);
  color: white;
}

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

.primary-button:active,
.soft-button:active,
.ghost-button:active {
  transform: translateY(1px);
}

.soft-button {
  background: #e8f2ee;
  color: var(--teal-dark);
  border-color: #c5ddd5;
}

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

.ghost-button.danger {
  color: #9a3827;
  border-color: #e2b7aa;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.stat-block {
  min-height: 78px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfaf6 100%);
  padding: 13px 15px;
  box-shadow: var(--shadow-light);
}

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

.stat-block strong {
  display: block;
  margin-top: 5px;
  font-size: 26px;
  line-height: 1.05;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: grid;
  gap: 20px;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.panel,
.focus-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(251, 250, 246, 0.92);
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel-heading,
.section-title-row,
.focus-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
}

.daily-schedule {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.daily-schedule label {
  display: grid;
  gap: 7px;
  color: #37423e;
  font-size: 13px;
}

.plan-table {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  overflow-x: auto;
  box-shadow: var(--shadow-light);
  margin-bottom: 12px;
}

.plan-header {
  display: grid;
  grid-template-columns: 58px 170px minmax(180px, 1fr) 92px 92px 82px 150px 88px 38px;
  gap: 8px;
  color: #52625d;
  font-size: 12px;
  padding: 11px 12px;
  min-width: 1000px;
  background: #edf3ef;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
}

.plan-list {
  display: grid;
  gap: 0;
  margin-bottom: 0;
}

.plan-row {
  display: grid;
  grid-template-columns: 58px 170px minmax(180px, 1fr) 92px 92px 82px 150px 88px 38px;
  gap: 8px;
  align-items: center;
  min-width: 1000px;
  padding: 10px 12px;
  border-bottom: 1px solid #edf0ec;
  background: #ffffff;
}

.plan-row:nth-child(even) {
  background: #fbfcfa;
}

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

.plan-row:hover {
  background: #f6faf7;
}

.plan-row .compact-button {
  min-height: 34px;
  padding: 0 8px;
}

.plan-upload {
  display: grid;
  gap: 4px;
}

.plan-upload input {
  font-size: 12px;
  padding: 7px;
  background: #fbfcfa;
}

.plan-status {
  color: #4f625d;
  font-size: 12px;
  line-height: 1.35;
  font-weight: 650;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #cfd7d1;
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
  padding: 9px 10px;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(20, 108, 99, 0.12);
  outline: none;
}

textarea {
  resize: vertical;
}

.field-label,
.review-grid label,
.settings-grid label,
.dialog-body label {
  display: grid;
  gap: 7px;
  color: #37423e;
  font-size: 13px;
}

.compact-panel {
  display: grid;
  gap: 10px;
}

.task-section {
  display: grid;
  gap: 12px;
}

.secondary-details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.68);
  box-shadow: var(--shadow-light);
}

.secondary-details summary {
  cursor: pointer;
  color: #41504c;
  font-weight: 750;
  padding: 14px 16px;
}

.secondary-details[open] {
  background: var(--surface);
}

.secondary-details[open] summary {
  border-bottom: 1px solid var(--line);
}

.secondary-details .task-section {
  padding: 16px;
}

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

.weekly-task-groups {
  display: grid;
  gap: 18px;
}

.weekly-group {
  display: grid;
  gap: 10px;
}

.weekly-group-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.weekly-group-heading h4 {
  margin: 0;
  font-size: 18px;
}

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

.task-card,
.reward-card {
  display: grid;
  gap: 12px;
  align-content: start;
  min-height: 244px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 16px;
  box-shadow: var(--shadow-light);
}

.task-card.done {
  border-color: #8fc3b4;
  background: #fbfffd;
}

.task-card h4,
.reward-card h4 {
  margin: 0;
  font-size: 17px;
}

.card-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.score-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 9px;
  background: var(--blue-soft);
  color: #25536d;
  font-size: 13px;
  white-space: nowrap;
}

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

.status-pill.pending {
  background: #efe7d4;
  color: #76551b;
}

.task-form {
  display: grid;
  gap: 10px;
}

.check-list {
  display: grid;
  gap: 7px;
}

.check-list label {
  display: flex;
  gap: 8px;
  align-items: center;
  color: #37423e;
  font-size: 13px;
}

.check-list input {
  width: 18px;
  height: 18px;
}

.file-note {
  color: var(--muted);
  font-size: 12px;
  min-height: 18px;
}

.focus-panel {
  max-width: 780px;
}

.focus-header select {
  max-width: 300px;
}

.timer-face {
  display: grid;
  place-items: center;
  min-height: 190px;
  border-radius: 8px;
  border: 1px solid #bdd8d2;
  background: #f7fbf8;
  font-variant-numeric: tabular-nums;
  font-size: 76px;
  font-weight: 800;
  color: var(--teal-dark);
}

.timer-progress {
  height: 12px;
  border-radius: 8px;
  background: #e5e0d5;
  overflow: hidden;
  margin: 14px 0;
}

.timer-progress div {
  height: 100%;
  width: 0;
  background: var(--teal);
}

.focus-quick-actions {
  margin-top: 16px;
}

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

.ledger-row {
  display: grid;
  grid-template-columns: 150px 1fr auto;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

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

.ledger-points {
  font-weight: 800;
  color: var(--teal-dark);
}

.ledger-points.negative {
  color: #9a3827;
}

.reward-card {
  min-height: 190px;
}

.reward-card .price {
  font-size: 28px;
  font-weight: 800;
  color: var(--teal-dark);
}

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

.weekly-summary {
  margin-top: 16px;
}

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

.summary-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.summary-item strong {
  display: block;
  margin-top: 5px;
  font-size: 21px;
}

dialog {
  border: 0;
  border-radius: 8px;
  padding: 0;
  width: min(560px, calc(100vw - 28px));
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.25);
}

dialog::backdrop {
  background: rgba(23, 29, 27, 0.42);
}

.dialog-body {
  display: grid;
  gap: 14px;
  padding: 18px;
  background: var(--surface);
}

.button-row.end {
  justify-content: flex-end;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  pointer-events: none;
  border-radius: 8px;
  background: #23332f;
  color: #fffdf7;
  padding: 11px 14px;
  box-shadow: var(--shadow);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
  z-index: 10;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 1040px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .app-shell.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .app-shell.sidebar-collapsed .sidebar {
    display: none;
  }

  .nav-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .split-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .main-view {
    padding: 16px;
  }

  .topbar,
  .panel-heading,
  .section-title-row,
  .focus-header {
    align-items: stretch;
    flex-direction: column;
  }

  .stats-grid,
  .task-grid,
  .reward-grid,
  .weekly-group .task-grid,
  .review-grid,
  .settings-grid,
  .weekly-summary {
    grid-template-columns: 1fr;
  }

  .plan-row {
    grid-template-columns: 1fr;
    min-width: 0;
    padding: 12px;
  }

  .plan-header {
    display: none;
  }

  .plan-table {
    overflow-x: visible;
  }

  .daily-schedule {
    grid-template-columns: 1fr;
  }

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

  .timer-face {
    min-height: 150px;
    font-size: 52px;
  }
}
