:root {
  --bg: #f3f1ec;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-strong: rgba(255, 255, 255, 0.92);
  --line: rgba(18, 24, 32, 0.08);
  --text: #171b20;
  --muted: #707781;
  --deep-muted: #515862;
  --accent: #222831;
  --positive: #2f6a5d;
  --negative: #9a574b;
  --shadow: 0 24px 60px rgba(20, 26, 34, 0.08);
  --radius-lg: 30px;
  --radius-md: 20px;
  --radius-sm: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  font-family: "Avenir Next", "PingFang SC", "Noto Sans SC", "Helvetica Neue", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.9), transparent 28%),
    linear-gradient(135deg, #efede8 0%, #f7f5f1 46%, #ece9e2 100%);
  min-height: 100vh;
}

button,
input,
select {
  font: inherit;
}

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

.sidebar {
  padding: 28px 22px;
  border-right: 1px solid var(--line);
  backdrop-filter: blur(18px);
  background: rgba(248, 246, 241, 0.72);
}

.main {
  padding: 30px;
}

.brand-block,
.panel,
.card,
.drawer-panel {
  background: var(--panel);
  backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow: var(--shadow);
}

.brand-block,
.panel {
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 18px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 10px;
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted);
}

.brand-block h1,
.hero h2,
.card h3,
.drawer-panel h3 {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", "Songti SC", serif;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.brand-block h1 {
  font-size: 34px;
  line-height: 1.05;
  margin-bottom: 12px;
}

.muted,
.footnote {
  color: var(--muted);
  line-height: 1.7;
}

.footnote {
  font-size: 12px;
}

.share-hint {
  margin: 12px 0 0;
}

.annual-note {
  margin: 14px 0 0;
}

.panel-header,
.card-header,
.section-head-inline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.status-dot,
.pill {
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--deep-muted);
  background: rgba(27, 32, 38, 0.05);
  border: 1px solid rgba(27, 32, 38, 0.08);
}

.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0 18px;
}

.meta-grid label,
.field-label {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--muted);
}

.meta-grid strong {
  font-size: 14px;
}

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

.action-stack.compact {
  grid-template-columns: 1fr 1fr;
  margin-top: 10px;
}

.btn,
.icon-btn,
select,
input {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.btn {
  min-height: 44px;
  padding: 0 16px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease;
}

.btn:hover,
.icon-btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--accent);
  color: #f5f4f0;
}

.btn-secondary {
  background: rgba(27, 32, 38, 0.06);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.6);
}

.upload-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.upload-btn input {
  display: none;
}

select,
input {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--text);
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 22px;
  gap: 18px;
}

.hero h2 {
  font-size: clamp(34px, 4vw, 56px);
  line-height: 0.98;
}

.hero-note {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  color: var(--deep-muted);
}

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

.kpi-card {
  border-radius: 24px;
  padding: 18px 20px;
  background: var(--panel-strong);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: var(--shadow);
}

.kpi-card label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 22px;
}

.kpi-card strong {
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.kpi-card span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 18px;
  margin-bottom: 18px;
}

.card {
  border-radius: var(--radius-lg);
  padding: 22px;
}

.wide-card {
  min-height: 420px;
}

.bars {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.bar-row {
  display: grid;
  grid-template-columns: 140px 1fr 70px;
  align-items: center;
  gap: 12px;
}

.bar-track {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: rgba(16, 24, 32, 0.08);
  overflow: hidden;
}

.bar-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: inherit;
}

.bar-value,
.bar-label {
  font-size: 13px;
}

.bar-value.positive,
.positive {
  color: var(--positive);
}

.bar-value.negative,
.negative {
  color: var(--negative);
}

.donut-layout {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 20px;
  align-items: center;
  margin-top: 22px;
}

.donut {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  position: relative;
}

.donut::after {
  content: "";
  position: absolute;
  inset: 28px;
  border-radius: 50%;
  background: rgba(246, 245, 241, 0.96);
  box-shadow: inset 0 0 0 1px rgba(18, 24, 32, 0.05);
}

.legend {
  display: grid;
  gap: 12px;
}

.legend-item {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  gap: 10px;
  align-items: center;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.manager-chart {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  min-height: 280px;
  padding-top: 24px;
  margin-top: 10px;
}

.year-bar {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 10px;
  align-items: center;
}

.year-stick {
  width: 100%;
  min-height: 2px;
  border-radius: 20px 20px 6px 6px;
  background: linear-gradient(180deg, rgba(24, 32, 40, 0.96), rgba(24, 32, 40, 0.38));
}

.year-stick.negative {
  background: linear-gradient(180deg, rgba(154, 87, 75, 0.94), rgba(154, 87, 75, 0.28));
}

.year-label,
.year-value {
  font-size: 12px;
  color: var(--muted);
}

.mini-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
}

.mini-stat {
  padding: 14px;
  border-radius: 18px;
  background: rgba(20, 26, 34, 0.04);
}

.mini-stat span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.mini-stat strong {
  font-size: 22px;
}

.table-wrap {
  overflow: auto;
  margin-top: 16px;
}

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

.compact-table table {
  min-width: 100%;
}

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

thead th {
  color: var(--muted);
  font-weight: 500;
}

.sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.sort-arrows {
  display: inline-flex;
  flex-direction: column;
  line-height: 0.8;
  font-size: 10px;
  color: rgba(23, 27, 32, 0.28);
}

.sort-btn.active {
  color: var(--text);
}

.sort-btn.asc .sort-arrows .up,
.sort-btn.desc .sort-arrows .down {
  color: var(--text);
}

tbody tr:hover {
  background: rgba(18, 24, 32, 0.025);
}

.drawer.hidden {
  display: none;
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 20;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 18, 22, 0.28);
  backdrop-filter: blur(8px);
}

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(760px, 100vw);
  padding: 24px;
  background: rgba(247, 245, 240, 0.96);
  overflow: auto;
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}

.icon-btn {
  width: 42px;
  height: 42px;
  background: rgba(27, 32, 38, 0.06);
  cursor: pointer;
}

.drawer-section {
  border-top: 1px solid var(--line);
  padding-top: 20px;
  margin-top: 20px;
}

.monthly-edit-grid {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.edit-row {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) 150px 150px;
  gap: 12px;
  align-items: center;
}

.row-meta strong,
.row-meta span {
  display: block;
}

.row-meta span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

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

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

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

@media (max-width: 720px) {
  .main,
  .sidebar {
    padding: 18px;
  }

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

  .hero-note {
    align-items: flex-start;
  }

  .donut-layout,
  .meta-grid,
  .action-stack.compact,
  .mini-stats,
  .add-form-grid,
  .edit-row {
    grid-template-columns: 1fr;
  }

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

  .manager-chart {
    gap: 10px;
  }
}

body.readonly-mode .action-stack,
body.readonly-mode #openUpdatePanel,
body.readonly-mode #resetSeed,
body.readonly-mode #exportData,
body.readonly-mode .upload-btn,
body.readonly-mode .drawer {
  display: none !important;
}
