:root {
  color-scheme: light;
  --bg: #f5f6f1;
  --surface: #ffffff;
  --surface-2: #eef2ec;
  --ink: #20231f;
  --muted: #687066;
  --line: #d8ded2;
  --line-strong: #bdc7ba;
  --teal: #08736f;
  --teal-deep: #075b58;
  --wine: #8a3446;
  --brass: #9f6b2f;
  --violet: #654a7b;
  --danger: #a13d32;
  --income: #08775b;
  --expense: #a04432;
  --shadow: 0 18px 45px rgba(37, 44, 34, 0.08);
  --radius: 8px;
  --sidebar: 292px;
  --icon-peak: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 19h18'/%3E%3Cpath d='M5 19l5-9 4 6 3-5 2 3'/%3E%3C/svg%3E");
  --icon-home: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 11.5 12 4l9 7.5'/%3E%3Cpath d='M5 10.5V20h14v-9.5'/%3E%3Cpath d='M9 20v-6h6v6'/%3E%3C/svg%3E");
  --icon-room: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 5h12l4 4v10H4z'/%3E%3Cpath d='M16 5v4h4'/%3E%3Cpath d='M8 19v-7h4v7'/%3E%3C/svg%3E");
  --icon-npc: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 12a4 4 0 1 0-4-4 4 4 0 0 0 4 4Z'/%3E%3Cpath d='M4 20c1.7-3.5 5-5 8-5s6.3 1.5 8 5'/%3E%3Cpath d='M9 9l1.5 1.5L14 8'/%3E%3C/svg%3E");
  --icon-finance: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cellipse cx='12' cy='6' rx='6.5' ry='3.5'/%3E%3Cpath d='M5.5 6v6.5C5.5 14.4 8.4 16 12 16s6.5-1.6 6.5-3.5V6'/%3E%3Cpath d='M5.5 12.5V17c0 1.9 2.9 3.5 6.5 3.5s6.5-1.6 6.5-3.5v-4.5'/%3E%3C/svg%3E");
  --icon-calendar: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='5' width='16' height='15' rx='2'/%3E%3Cpath d='M8 3v4M16 3v4M4 9h16'/%3E%3Cpath d='M8 13h3M13 13h3M8 17h3M13 17h3'/%3E%3C/svg%3E");
  --icon-campfire: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3c1.5 2.3 1 3.9-.4 5.5 2.5-.5 4.9 1.1 5.7 3.7.9 2.8-.5 5.5-3 7.1-1.5 1-3.6 1.7-5.7 1.2-3-.7-5-3.3-5-6.4 0-2.6 1.7-4.9 4.1-5.9-.3 1.9.5 3.2 1.7 4.2C11.3 10.2 13 7.8 12 3Z'/%3E%3Cpath d='M7 20h10'/%3E%3C/svg%3E");
  --icon-market: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 8h16l-1.2 12H5.2z'/%3E%3Cpath d='M8 8a4 4 0 0 1 8 0'/%3E%3Cpath d='M9 12h6'/%3E%3C/svg%3E");
  --icon-settings: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='3.5'/%3E%3Cpath d='M19 12a7 7 0 0 0-.1-1l2-1.2-2-3.4-2.2.8a7 7 0 0 0-1.7-1l-.3-2.3H9.3L9 5.2a7 7 0 0 0-1.7 1l-2.2-.8-2 3.4 2 1.2a7 7 0 0 0 0 2l-2 1.2 2 3.4 2.2-.8a7 7 0 0 0 1.7 1l.3 2.3h4.4l.3-2.3a7 7 0 0 0 1.7-1l2.2.8 2-3.4-2-1.2c.1-.3.1-.6.1-1Z'/%3E%3C/svg%3E");
  --icon-edit: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 20h4l10-10-4-4L4 16z'/%3E%3Cpath d='M14 6l4 4'/%3E%3C/svg%3E");
  --icon-trash: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 7h16'/%3E%3Cpath d='M9 7V5h6v2'/%3E%3Cpath d='M7 7l1 12h8l1-12'/%3E%3Cpath d='M10 11v5M14 11v5'/%3E%3C/svg%3E");
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  letter-spacing: 0;
  background:
    linear-gradient(90deg, rgba(8, 115, 111, 0.05) 1px, transparent 1px),
    linear-gradient(0deg, rgba(101, 74, 123, 0.04) 1px, transparent 1px),
    var(--bg);
  background-size: 44px 44px;
}

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

button {
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 28px 22px;
  color: #f4f6ef;
  background: #242822;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius);
  color: #f7e8c5;
  background: #7c4731;
  font-weight: 800;
  font-size: 0;
  line-height: 0;
  overflow: hidden;
}

.brand-mark::before {
  content: "";
  width: 22px;
  height: 22px;
  background: currentColor;
  -webkit-mask: var(--icon-peak) center / contain no-repeat;
  mask: var(--icon-peak) center / contain no-repeat;
}

.brand p,
.brand span {
  margin: 0;
}

.brand p {
  font-size: 1.25rem;
  font-weight: 800;
}

.brand span {
  display: block;
  margin-top: 2px;
  color: rgba(244, 246, 239, 0.68);
  font-size: 0.9rem;
}

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

.nav-button {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: rgba(244, 246, 239, 0.78);
  background: transparent;
  text-align: left;
}

.nav-button span {
  width: 22px;
  color: rgba(247, 232, 197, 0.7);
}

.nav-button > span[aria-hidden="true"] {
  display: inline-block;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  color: inherit;
  font-size: 0;
  line-height: 0;
  background: currentColor;
  -webkit-mask: var(--icon, var(--icon-home)) center / contain no-repeat;
  mask: var(--icon, var(--icon-home)) center / contain no-repeat;
}

.nav-button[data-view-target="dashboard"] > span[aria-hidden="true"] { --icon: var(--icon-home); }
.nav-button[data-view-target="rooms"] > span[aria-hidden="true"] { --icon: var(--icon-room); }
.nav-button[data-view-target="npcs"] > span[aria-hidden="true"] { --icon: var(--icon-npc); }
.nav-button[data-view-target="finance"] > span[aria-hidden="true"] { --icon: var(--icon-finance); }
.nav-button[data-view-target="calendar"] > span[aria-hidden="true"] { --icon: var(--icon-calendar); }
.nav-button[data-view-target="campfire"] > span[aria-hidden="true"] { --icon: var(--icon-campfire); }
.nav-button[data-view-target="market"] > span[aria-hidden="true"] { --icon: var(--icon-market); }
.nav-button[data-view-target="settings"] > span[aria-hidden="true"] { --icon: var(--icon-settings); }

.nav-button:hover,
.nav-button.active {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.11);
  background: rgba(255, 255, 255, 0.08);
}

.side-status {
  margin-top: auto;
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
}

.side-status div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.side-status span {
  color: rgba(244, 246, 239, 0.64);
  font-size: 0.84rem;
}

.side-status strong {
  color: #f8efdc;
  font-size: 0.94rem;
  text-align: right;
}

.workspace {
  width: 100%;
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 22px;
}

.topbar h1 {
  margin: 4px 0 0;
  font-size: 2rem;
  line-height: 1.1;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.day-control {
  display: flex;
  align-items: end;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.74);
  box-shadow: var(--shadow);
}

.day-control label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.day-control input {
  width: 120px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.view[hidden] {
  display: none !important;
}

.notice,
.toast {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid #e6c98f;
  border-radius: var(--radius);
  color: #624213;
  background: #fff6df;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10;
  max-width: 360px;
  border-color: #b9d7cf;
  color: #0c4c46;
  background: #ebfbf6;
  box-shadow: var(--shadow);
}

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

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

.metric,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.metric {
  min-height: 104px;
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 18px;
}

.metric.large {
  min-height: 120px;
}

.metric span {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.metric strong {
  overflow-wrap: anywhere;
  font-size: 1.75rem;
  line-height: 1.05;
}

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

.metric-actions {
  margin-top: 6px;
  display: flex;
  justify-content: flex-start;
}

.panel {
  padding: 18px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(340px, 0.9fr);
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}

.dashboard-calendar-panel {
  min-height: 100%;
}

.calendar-mini {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 8px;
  max-height: 780px;
  overflow: auto;
  padding-right: 4px;
}

.calendar-mini-day {
  min-height: 86px;
  aspect-ratio: 0.92;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 6px;
  padding: 8px;
  border: 1px solid rgba(208, 164, 88, 0.16);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.015)),
    rgba(18, 21, 18, 0.82);
  overflow: hidden;
}

.calendar-mini-day.today {
  border-color: rgba(72, 208, 196, 0.58);
  box-shadow: 0 0 0 1px rgba(72, 208, 196, 0.2) inset;
}

.calendar-mini-day.has-entries {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)),
    rgba(20, 24, 21, 0.9);
}

.calendar-mini-day header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.calendar-mini-day strong {
  color: #fff4da;
  font-family: var(--font-display);
  font-size: 0.95rem;
  line-height: 1;
}

.calendar-mini-day header span {
  color: rgba(243, 234, 216, 0.56);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  flex: 0 0 auto;
}

.calendar-mini-items {
  display: grid;
  align-content: start;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
}

.calendar-mini-dots {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 20px;
  min-width: 0;
  overflow: hidden;
}

.calendar-mini-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 999px;
  border: 1px solid transparent;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.28) inset;
}

.calendar-mini-dot.income {
  background: #50dba6;
  border-color: rgba(140, 255, 205, 0.42);
}

.calendar-mini-dot.expense {
  background: #ef6b63;
  border-color: rgba(255, 160, 148, 0.42);
}

.calendar-mini-dot.event {
  background: #5a9dfc;
  border-color: rgba(163, 205, 255, 0.5);
}

.calendar-mini-empty {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: rgba(243, 234, 216, 0.12);
  border: 1px solid rgba(243, 234, 216, 0.08);
}

.calendar-mini-more {
  color: rgba(243, 234, 216, 0.52);
  font-size: 0.62rem;
  line-height: 1;
  margin-left: 2px;
  transform: translateY(1px);
}

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

.section-header h2 {
  margin: 4px 0 0;
  font-size: 1.2rem;
  line-height: 1.2;
}

.section-header.floating {
  margin: 0 0 10px;
}

.section-header.lower {
  margin-top: 20px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

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

.button.small {
  min-height: 34px;
  padding: 8px 12px;
  font-size: 0.84rem;
}

.finance-balance-panel {
  margin-top: 14px;
}

.finance-balance-panel .inline-form {
  margin-top: 0;
}

.button-row.separated {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.button {
  min-height: 40px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 800;
  text-decoration: none;
}

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

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

.button.subtle {
  color: var(--teal-deep);
  border-color: #acd2ca;
  background: #edf8f5;
}

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

.button.danger {
  color: #ffffff;
  background: var(--danger);
}

input,
textarea,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 9px 11px;
  color: var(--ink);
  background: #ffffff;
  outline: none;
}

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

input:focus,
textarea:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(8, 115, 111, 0.13);
}

label {
  display: grid;
  gap: 7px;
  color: #42483f;
  font-size: 0.9rem;
  font-weight: 800;
}

.stacked-form {
  display: grid;
  gap: 13px;
}

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

.inline-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 140px 130px 110px auto;
  gap: 10px;
  margin-bottom: 16px;
}

.check-line {
  display: flex;
  align-items: center;
  gap: 9px;
}

.check-line input,
fieldset input {
  width: auto;
  min-height: auto;
}

.two-column {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
}

.two-column.wide-left {
  grid-template-columns: 1fr;
}

.form-panel {
  position: relative;
  top: 0;
}

.composer-body {
  margin-top: 14px;
}

.composer-body[hidden] {
  display: none !important;
}

.content-column {
  min-width: 0;
}

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.toolbar.split {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) 180px 180px 170px;
}

.room-grid,
.npc-grid,
.market-grid,
.source-list,
.list-stack,
.compact-stock,
.ledger-preview {
  display: grid;
  gap: 12px;
}

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

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

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

.market-sections {
  display: grid;
  gap: 16px;
}

.market-section {
  padding-top: 18px;
}

.room-card,
.npc-card,
.market-card,
.source-card,
.due-card,
.ledger-item,
.empty-state {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.room-card,
.market-card,
.source-card,
.due-card,
.ledger-item,
.empty-state {
  padding: 14px;
}

.room-card header,
.source-card header,
.market-card header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 10px;
  margin-bottom: 10px;
}

.room-card h3,
.source-card h3,
.market-card h3,
.npc-card h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.25;
}

.room-card p,
.source-card p,
.market-card p,
.npc-card p,
.empty-state p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.muted {
  color: var(--muted);
}

.card-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.icon-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: #f9faf7;
}

.icon-button:hover {
  border-color: var(--teal);
  color: var(--teal-deep);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  max-width: 100%;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #465047;
  background: #f6f8f4;
  font-size: 0.78rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.chip.income {
  color: #07543f;
  border-color: #b7d9c9;
  background: #edf8f2;
}

.chip.expense {
  color: #7b2b22;
  border-color: #ecc6bf;
  background: #fff1ee;
}

.chip.premium {
  color: #5d3d77;
  border-color: #d8c7e7;
  background: #f7f0fc;
}

.chip.warn {
  color: #74500c;
  border-color: #ead5a5;
  background: #fff7e1;
}

.npc-card {
  overflow: hidden;
}

.npc-card-body {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  min-height: 164px;
}

.npc-portrait {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 164px;
  color: #fbf5e7;
  background:
    linear-gradient(135deg, rgba(138, 52, 70, 0.92), rgba(8, 115, 111, 0.86)),
    #8a3446;
  font-size: 1.7rem;
  font-weight: 900;
}

.npc-portrait img {
  width: 100%;
  height: 100%;
  min-height: 164px;
  object-fit: cover;
}

.npc-info {
  min-width: 0;
  padding: 14px;
}

.npc-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.npc-card .card-actions {
  margin-top: 12px;
}

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

.due-card strong {
  display: block;
  margin-bottom: 2px;
}

.due-card .amount {
  font-weight: 900;
  text-align: right;
}

.amount.income,
.type-income {
  color: var(--income);
}

.amount.expense,
.type-expense {
  color: var(--expense);
}

.source-card {
  display: grid;
  gap: 8px;
}

.source-meta,
.market-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.ledger-panel {
  margin-top: 16px;
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

td:last-child,
th:last-child {
  text-align: right;
}

.market-controls {
  margin-bottom: 14px;
}

.market-status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.market-settings {
  display: grid;
  grid-template-columns: 170px 170px minmax(190px, 1fr) minmax(260px, 1.1fr) auto;
  gap: 10px;
  align-items: end;
}

fieldset {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 40px;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
}

legend {
  padding: 0 4px;
  color: #42483f;
  font-size: 0.82rem;
  font-weight: 800;
}

fieldset label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.84rem;
}

.market-card {
  display: grid;
  gap: 10px;
}

.market-card .price-line {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}

.market-card .price-line span {
  color: var(--muted);
  font-size: 0.82rem;
}

.market-card .price-line strong {
  font-size: 1.12rem;
}

.market-link {
  color: var(--teal-deep);
  font-weight: 800;
  text-decoration: none;
}

.market-link:hover {
  text-decoration: underline;
}

.empty-state {
  color: var(--muted);
}

.empty-state strong {
  display: block;
  margin-bottom: 3px;
  color: var(--ink);
}

@media (max-width: 1180px) {
  .dashboard-grid,
  .two-column,
  .two-column.wide-left {
    grid-template-columns: 1fr;
  }

  .form-panel {
    position: static;
  }

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

  .market-settings,
  .inline-form,
  .toolbar.split {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .sidebar {
    position: static;
    height: auto;
    padding: 18px;
  }

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

  .nav-button {
    justify-content: center;
    text-align: center;
  }

  .nav-button span {
    width: auto;
  }

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

  .side-status div {
    display: grid;
  }

  .side-status strong {
    text-align: left;
  }

  .workspace {
    padding: 18px;
  }

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

  .topbar-actions {
    width: 100%;
    align-items: stretch;
    justify-content: stretch;
  }

  .user-control {
    min-width: 0;
  }

  .day-control {
    align-items: stretch;
  }

  .metric-grid,
  .finance-summary,
  .room-grid,
  .npc-grid,
  .market-grid {
    grid-template-columns: 1fr;
  }

  .toolbar,
  .toolbar.split,
  .form-row,
  .inline-form,
  .market-settings {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .npc-card-body {
    grid-template-columns: 96px minmax(0, 1fr);
  }
}

@media (max-width: 560px) {
  .nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .side-status {
    grid-template-columns: 1fr;
  }

  .day-control {
    display: grid;
  }

  .day-control input {
    width: 100%;
  }

  .topbar-actions {
    gap: 10px;
  }

  .user-control,
  .day-control {
    width: 100%;
  }

  .section-header,
  .due-card,
  .market-card .price-line {
    align-items: stretch;
    flex-direction: column;
    grid-template-columns: 1fr;
  }

  .due-card .amount {
    text-align: left;
  }

  .npc-card-body {
    grid-template-columns: 1fr;
  }

  .npc-portrait,
  .npc-portrait img {
    min-height: 190px;
  }
}

/* Obsidian war-room redesign */
:root {
  color-scheme: dark;
  --bg: #0b0c0b;
  --surface: #151816;
  --surface-2: #1e221e;
  --ink: #f3ead8;
  --muted: #b2a996;
  --line: rgba(202, 173, 112, 0.22);
  --line-strong: rgba(231, 197, 123, 0.42);
  --teal: #34b0a2;
  --teal-deep: #7be3d2;
  --wine: #9c3248;
  --brass: #d0a458;
  --violet: #9f79b9;
  --danger: #b84c3f;
  --income: #70d6a3;
  --expense: #ff8b72;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.035);
  --radius: 6px;
  --sidebar: 304px;
  --font-display: "Cinzel", "Constantia", "Times New Roman", serif;
  --font-body: "Alegreya Sans", "Candara", "Trebuchet MS", sans-serif;
  --font-mono: "Cascadia Mono", "Consolas", monospace;
}

html {
  background: var(--bg);
}

body {
  position: relative;
  overflow-x: hidden;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  word-spacing: 0.025em;
  background:
    linear-gradient(115deg, rgba(116, 26, 39, 0.16), transparent 34%),
    linear-gradient(245deg, rgba(29, 107, 100, 0.16), transparent 38%),
    repeating-linear-gradient(90deg, rgba(222, 188, 113, 0.045) 0 1px, transparent 1px 66px),
    repeating-linear-gradient(0deg, rgba(222, 188, 113, 0.035) 0 1px, transparent 1px 66px),
    #0b0c0b;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    linear-gradient(135deg, transparent 0 47%, rgba(215, 165, 73, 0.12) 47.1% 47.8%, transparent 48%),
    linear-gradient(45deg, transparent 0 74%, rgba(55, 177, 163, 0.08) 74.1% 74.7%, transparent 75%),
    radial-gradient(ellipse at top, rgba(255, 229, 171, 0.08), transparent 55%);
  opacity: 0.9;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 9px 9px;
  mix-blend-mode: screen;
  opacity: 0.16;
}

::selection {
  color: #130f0b;
  background: var(--brass);
}

button,
input,
textarea,
select {
  font-family: var(--font-body);
}

.sidebar {
  isolation: isolate;
  overflow: hidden;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 20%),
    linear-gradient(135deg, #151913, #0b0d0b 68%);
  border-right: 1px solid rgba(208, 164, 88, 0.34);
  box-shadow: 14px 0 60px rgba(0, 0, 0, 0.35);
}

.sidebar::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    repeating-linear-gradient(135deg, rgba(208, 164, 88, 0.08) 0 1px, transparent 1px 18px),
    linear-gradient(180deg, rgba(156, 50, 72, 0.15), transparent 42%);
  opacity: 0.42;
}

.brand {
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(208, 164, 88, 0.26);
}

.brand-mark {
  width: 54px;
  height: 54px;
  border-color: rgba(250, 218, 146, 0.54);
  color: #ffe3a7;
  background:
    linear-gradient(135deg, rgba(156, 50, 72, 0.92), rgba(112, 62, 28, 0.92)),
    #6a2d2d;
  font-family: var(--font-display);
  font-size: 0.98rem;
  box-shadow: 0 0 0 5px rgba(208, 164, 88, 0.08), 0 18px 42px rgba(0, 0, 0, 0.42);
}

.brand p,
.topbar h1,
.section-header h2 {
  font-family: var(--font-display);
}

.brand p {
  color: #fff6dd;
  font-size: 1.34rem;
  letter-spacing: 0.02em;
}

.brand span {
  color: rgba(243, 234, 216, 0.68);
}

.nav-list {
  gap: 10px;
}

.nav-button {
  position: relative;
  min-height: 48px;
  color: rgba(243, 234, 216, 0.74);
  border-color: rgba(208, 164, 88, 0.08);
  background: rgba(255, 255, 255, 0.015);
  transition: transform 180ms ease, color 180ms ease, border-color 180ms ease, background 180ms ease;
}

.nav-button::after {
  content: "";
  position: absolute;
  inset: 8px auto 8px -1px;
  width: 2px;
  background: var(--brass);
  transform: scaleY(0);
  transform-origin: center;
  transition: transform 180ms ease;
}

.nav-button span {
  color: rgba(231, 197, 123, 0.84);
}

.nav-button:hover,
.nav-button.active {
  color: #fff8e8;
  border-color: rgba(231, 197, 123, 0.34);
  background: linear-gradient(90deg, rgba(208, 164, 88, 0.16), rgba(255, 255, 255, 0.035));
  transform: translateX(3px);
}

.nav-button:hover::after,
.nav-button.active::after {
  transform: scaleY(1);
}

.side-status {
  padding: 16px;
  border-color: rgba(231, 197, 123, 0.28);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.018)),
    rgba(20, 23, 19, 0.84);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 18px 38px rgba(0, 0, 0, 0.24);
}

.side-status span {
  color: rgba(243, 234, 216, 0.58);
}

.side-status strong {
  color: #ffe2a5;
  font-family: var(--font-mono);
}

.workspace {
  position: relative;
  padding: 30px 34px 52px;
}

.topbar {
  min-height: 86px;
  align-items: start;
  margin-bottom: 28px;
}

.topbar h1 {
  margin-top: 6px;
  color: #fff5dc;
  font-size: clamp(2.3rem, 4vw, 4.7rem);
  font-weight: 800;
  line-height: 0.95;
  text-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

.topbar-actions {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

body.role-player .topbar-actions,
body.role-player .topbar-actions * {
  display: none !important;
}

body.role-player .topbar-actions {
  width: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

.profile-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  margin-top: 10px;
}

.profile-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.profile-line strong {
  color: #fff6de;
  font-size: 0.98rem;
  font-weight: 800;
}

.user-control {
  display: grid;
  gap: 6px;
  min-width: 220px;
}

.user-control label {
  margin: 0;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(208, 164, 88, 0.34);
  color: #fff1c2;
  background: rgba(208, 164, 88, 0.09);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0;
}

.role-badge.admin {
  border-color: rgba(208, 164, 88, 0.45);
  background: rgba(208, 164, 88, 0.14);
}

.role-badge.player {
  border-color: rgba(126, 255, 227, 0.34);
  background: rgba(126, 255, 227, 0.1);
  color: #d7fff7;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at top, rgba(88, 143, 122, 0.12), transparent 34%),
    rgba(7, 8, 8, 0.88);
  backdrop-filter: blur(14px);
}

.auth-overlay[hidden] {
  display: none;
}

.auth-card {
  width: min(520px, 100%);
  padding: 28px;
  border: 1px solid rgba(231, 197, 123, 0.26);
  border-radius: var(--radius);
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015)),
    rgba(17, 20, 18, 0.98);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}

.auth-brand {
  margin-bottom: 18px;
}

.auth-card h2 {
  margin: 0 0 10px;
  font-size: 1.65rem;
}

.auth-copy,
.auth-note {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.45;
}

.auth-note {
  margin-top: 16px;
  margin-bottom: 0;
}

.eyebrow {
  color: var(--brass);
  font-size: 0.73rem;
  letter-spacing: 0.08em;
}

.day-control {
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-color: rgba(231, 197, 123, 0.28);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.025)),
    rgba(18, 21, 18, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.day-control label,
label {
  color: rgba(243, 234, 216, 0.8);
}

.day-control.locked {
  opacity: 0.86;
}

.notice,
.toast {
  border-color: rgba(231, 197, 123, 0.52);
  color: #ffe8b6;
  background: rgba(78, 53, 21, 0.86);
  box-shadow: var(--shadow);
}

.toast {
  color: #dffff7;
  border-color: rgba(90, 223, 203, 0.46);
  background: rgba(13, 72, 68, 0.92);
}

.metric,
.panel,
.room-card,
.npc-card,
.market-card,
.source-card,
.due-card,
.ledger-item,
.empty-state {
  position: relative;
  overflow: hidden;
  border-color: var(--line);
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.018) 52%, rgba(208, 164, 88, 0.035)),
    rgba(18, 21, 18, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.metric::before,
.panel::before,
.room-card::before,
.npc-card::before,
.market-card::before,
.source-card::before,
.due-card::before,
.ledger-item::before,
.empty-state::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 229, 169, 0.52), transparent);
  opacity: 0.7;
}

.metric {
  min-height: 118px;
  padding: 20px;
}

.metric span {
  color: var(--muted);
  font-size: 0.84rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.metric strong {
  color: #fff8e7;
  font-family: var(--font-display);
  font-size: 2.15rem;
}

.panel {
  padding: 20px;
}

.section-header h2 {
  color: #fff4da;
  font-size: 1.34rem;
}

.dashboard-grid {
  gap: 18px;
}

.button {
  position: relative;
  overflow: hidden;
  min-height: 42px;
  border-radius: 5px;
  font-weight: 800;
  word-spacing: 0.08em;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.button::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 0 35%, rgba(255, 255, 255, 0.22) 48%, transparent 62% 100%);
  transform: translateX(-120%);
  transition: transform 450ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:hover::before {
  transform: translateX(120%);
}

.button.primary {
  color: #07110e;
  border-color: rgba(126, 255, 227, 0.42);
  background: linear-gradient(135deg, #8cebdc, #23a091);
  box-shadow: 0 14px 38px rgba(35, 160, 145, 0.24);
}

.button.primary:hover {
  background: linear-gradient(135deg, #b0fff2, #34b0a2);
}

.button.subtle {
  color: #ffe0a0;
  border-color: rgba(208, 164, 88, 0.42);
  background: rgba(208, 164, 88, 0.09);
}

.button.ghost {
  color: var(--ink);
  border-color: rgba(243, 234, 216, 0.24);
  background: rgba(255, 255, 255, 0.025);
}

.button.danger {
  color: #fff0e9;
  border-color: rgba(255, 139, 114, 0.34);
  background: linear-gradient(135deg, #973448, #5c1d29);
}

input,
textarea,
select {
  border-color: rgba(231, 197, 123, 0.28);
  color: var(--ink);
  background: rgba(5, 7, 6, 0.58);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

input::placeholder,
textarea::placeholder {
  color: rgba(178, 169, 150, 0.62);
}

select {
  color-scheme: dark;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(126, 255, 227, 0.72);
  box-shadow: 0 0 0 3px rgba(52, 176, 162, 0.16), 0 0 32px rgba(52, 176, 162, 0.12);
}

.toolbar {
  padding: 10px;
  border: 1px solid rgba(208, 164, 88, 0.16);
  border-radius: var(--radius);
  background: rgba(8, 10, 8, 0.52);
  backdrop-filter: blur(14px);
}

.room-grid,
.npc-grid,
.market-grid,
.source-list,
.list-stack,
.compact-stock,
.ledger-preview {
  gap: 14px;
}

.room-card,
.market-card,
.source-card,
.due-card,
.ledger-item,
.empty-state {
  padding: 16px;
}

.room-card,
.market-card,
.source-card,
.due-card,
.ledger-item,
.empty-state,
.npc-card {
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.room-card:hover,
.market-card:hover,
.source-card:hover,
.due-card:hover,
.ledger-item:hover,
.npc-card:hover {
  border-color: rgba(231, 197, 123, 0.48);
  box-shadow: 0 28px 78px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(208, 164, 88, 0.08);
  transform: translateY(-2px);
}

.room-card h3,
.source-card h3,
.market-card h3,
.npc-card h3 {
  color: #fff5dc;
  font-family: var(--font-display);
  font-size: 1.03rem;
}

.room-card p,
.source-card p,
.market-card p,
.npc-card p,
.empty-state p {
  color: rgba(243, 234, 216, 0.68);
}

.muted {
  color: rgba(243, 234, 216, 0.62);
}

.icon-button {
  display: grid;
  place-items: center;
  font-size: 0;
  line-height: 0;
  border-color: rgba(208, 164, 88, 0.28);
  color: #ffe1a2;
  background: rgba(255, 255, 255, 0.035);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.icon-button::before {
  content: "";
  width: 16px;
  height: 16px;
  background: currentColor;
  -webkit-mask: var(--icon, var(--icon-edit)) center / contain no-repeat;
  mask: var(--icon, var(--icon-edit)) center / contain no-repeat;
}

.icon-button[data-action^="edit-"] {
  --icon: var(--icon-edit);
}

.icon-button[data-action^="delete-"] {
  --icon: var(--icon-trash);
}

.icon-button:hover {
  border-color: rgba(126, 255, 227, 0.64);
  color: #b8fff3;
  background: rgba(52, 176, 162, 0.12);
  transform: translateY(-1px);
}

.chip {
  border-color: rgba(208, 164, 88, 0.26);
  color: #f0d8a5;
  background: rgba(208, 164, 88, 0.09);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
}

.chip.income {
  color: #b8ffd8;
  border-color: rgba(112, 214, 163, 0.38);
  background: rgba(112, 214, 163, 0.12);
}

.chip.expense {
  color: #ffc5b7;
  border-color: rgba(255, 139, 114, 0.42);
  background: rgba(255, 139, 114, 0.12);
}

.chip.premium {
  color: #e7c5ff;
  border-color: rgba(159, 121, 185, 0.46);
  background: rgba(159, 121, 185, 0.14);
}

.chip.warn {
  color: #ffe19b;
  border-color: rgba(208, 164, 88, 0.52);
  background: rgba(208, 164, 88, 0.16);
}

.npc-portrait {
  color: #fff0c7;
  background:
    linear-gradient(135deg, rgba(156, 50, 72, 0.94), rgba(15, 118, 109, 0.78)),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.08) 0 1px, transparent 1px 12px),
    #261512;
  font-family: var(--font-display);
  box-shadow: inset -1px 0 0 rgba(208, 164, 88, 0.22);
}

.npc-info {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.018), transparent);
}

.npc-meta,
.source-meta,
.market-meta {
  color: rgba(231, 214, 178, 0.62);
}

.amount.income,
.type-income {
  color: var(--income);
}

.amount.expense,
.type-expense {
  color: var(--expense);
}

table {
  color: var(--ink);
}

th,
td {
  border-bottom-color: rgba(208, 164, 88, 0.18);
}

th {
  color: var(--brass);
  letter-spacing: 0.08em;
}

fieldset {
  border-color: rgba(231, 197, 123, 0.28);
  background: rgba(5, 7, 6, 0.34);
}

legend {
  color: rgba(243, 234, 216, 0.82);
}

.market-card {
  min-height: 226px;
}

.market-card.rarity-uncommon {
  border-color: rgba(255, 168, 72, 0.82);
  background:
    linear-gradient(145deg, rgba(110, 61, 17, 0.2), rgba(17, 22, 20, 0.92) 54%, rgba(255, 168, 72, 0.12)),
    rgba(18, 21, 18, 0.84);
  box-shadow:
    0 28px 84px rgba(0, 0, 0, 0.48),
    0 0 0 1px rgba(255, 168, 72, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.market-card.rarity-uncommon::after {
  content: "";
  position: absolute;
  inset: auto -18px -18px auto;
  width: 116px;
  height: 116px;
  background: radial-gradient(circle, rgba(255, 168, 72, 0.22), transparent 64%);
  pointer-events: none;
}

.market-card.rarity-rare {
  border-color: rgba(74, 150, 255, 0.88);
  background:
    linear-gradient(160deg, rgba(74, 150, 255, 0.2), rgba(255, 255, 255, 0.016) 42%, rgba(78, 117, 214, 0.16)),
    rgba(18, 21, 18, 0.86);
  box-shadow:
    0 30px 90px rgba(0, 0, 0, 0.56),
    0 0 0 1px rgba(74, 150, 255, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.market-card.rarity-rare::after {
  content: "";
  position: absolute;
  inset: auto -12px -12px auto;
  width: 150px;
  height: 150px;
  background:
    radial-gradient(circle, rgba(74, 150, 255, 0.26), transparent 62%),
    radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.11), transparent 36%);
  pointer-events: none;
}

.market-card.rarity-rare h3 {
  color: #cfe3ff;
}

.market-card.rarity-uncommon h3 {
  color: #ffd79b;
}

.market-card .price-line {
  padding-top: 8px;
  border-top: 1px solid rgba(208, 164, 88, 0.18);
}

.market-card .price-line span {
  color: rgba(243, 234, 216, 0.55);
}

.market-card .price-line strong {
  color: #f4e6c9;
  font-family: var(--font-display);
  font-size: 1.34rem;
}

.market-card.rarity-rare .price-line strong {
  color: #d9ebff;
  text-shadow:
    0 0 18px rgba(74, 150, 255, 0.26),
    0 0 34px rgba(74, 150, 255, 0.12);
}

.chip-row.compact {
  justify-content: flex-end;
  margin-top: 0;
}

.market-card.rarity-uncommon .chip:first-child {
  color: #5e3306;
  border-color: rgba(255, 168, 72, 0.55);
  background: linear-gradient(180deg, rgba(255, 223, 177, 0.98), rgba(255, 184, 94, 0.88));
}

.market-card.rarity-rare .chip:first-child {
  color: #17365d;
  border-color: rgba(74, 150, 255, 0.68);
  background: linear-gradient(180deg, rgba(225, 238, 255, 0.98), rgba(153, 197, 255, 0.9));
}

.market-card.section-permanent {
  border-top: 3px solid rgba(231, 197, 123, 0.38);
}

.market-card.section-consumable {
  border-top: 3px solid rgba(126, 255, 227, 0.34);
}

.user-card {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
}

.user-card.active {
  border-color: rgba(126, 255, 227, 0.38);
  box-shadow: 0 24px 72px rgba(0, 0, 0, 0.42), 0 0 0 1px rgba(126, 255, 227, 0.08);
}

.market-card .market-meta .level-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid rgba(231, 197, 123, 0.38);
  border-radius: 999px;
  color: #fff2cd;
  background: rgba(231, 197, 123, 0.08);
  font-size: 0.92rem;
  font-weight: 900;
  letter-spacing: 0;
}

.market-card .chip.expense {
  color: #ffe9e7;
  border-color: rgba(184, 76, 63, 0.4);
  background: linear-gradient(180deg, rgba(184, 76, 63, 0.96), rgba(130, 33, 35, 0.88));
}

.market-link {
  color: #8cebdc;
  text-decoration-color: rgba(140, 235, 220, 0.34);
}

.empty-state strong {
  color: #fff5dc;
}

.campfire-intro {
  position: relative;
  overflow: hidden;
  margin-bottom: 16px;
  background:
    radial-gradient(circle at top right, rgba(255, 148, 72, 0.14), transparent 34%),
    radial-gradient(circle at left, rgba(126, 255, 227, 0.08), transparent 28%),
    linear-gradient(180deg, rgba(34, 19, 11, 0.98), rgba(14, 16, 14, 0.92));
}

.campfire-intro::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.04) 25%, transparent 25%) 0 0 / 18px 18px,
    linear-gradient(315deg, rgba(255, 255, 255, 0.03) 25%, transparent 25%) 0 0 / 18px 18px;
  opacity: 0.22;
}

.campfire-intro > * {
  position: relative;
  z-index: 1;
}

.campfire-note-summary {
  margin: 12px 0 0;
  color: rgba(246, 230, 201, 0.72);
  font-size: 0.96rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.campfire-editor {
  position: relative;
  margin-bottom: 16px;
}

.campfire-gallery-panel {
  margin-bottom: 16px;
}

#view-campfire {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

#view-campfire > section {
  width: 100%;
  min-width: 0;
}

.campfire-board {
  display: grid;
  gap: 14px;
}

.campfire-board-head {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid rgba(231, 197, 123, 0.24);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02)),
    rgba(19, 18, 16, 0.88);
}

.campfire-board-head h3 {
  margin: 2px 0 0;
  color: #fff7e1;
  font-family: var(--font-display);
  font-size: 1.28rem;
}

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

.campfire-lane {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 14px;
  border: 1px solid rgba(231, 197, 123, 0.18);
  border-radius: var(--radius);
  background: rgba(16, 18, 16, 0.84);
}

.campfire-lane header {
  display: grid;
  gap: 4px;
}

.campfire-lane h4 {
  margin: 0;
  color: #fff5dc;
  font-family: var(--font-display);
  font-size: 1rem;
}

.lane-short {
  border-top: 3px solid rgba(112, 214, 163, 0.82);
  background:
    linear-gradient(180deg, rgba(112, 214, 163, 0.08), rgba(255, 255, 255, 0.02)),
    rgba(16, 18, 16, 0.84);
}

.lane-medium {
  border-top: 3px solid rgba(255, 168, 72, 0.84);
  background:
    linear-gradient(180deg, rgba(255, 168, 72, 0.08), rgba(255, 255, 255, 0.02)),
    rgba(16, 18, 16, 0.84);
}

.lane-long {
  border-top: 3px solid rgba(158, 110, 255, 0.84);
  background:
    linear-gradient(180deg, rgba(158, 110, 255, 0.09), rgba(255, 255, 255, 0.02)),
    rgba(16, 18, 16, 0.84);
}

.campfire-goal-list {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.campfire-goal-item {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(231, 197, 123, 0.14);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.025);
}

.campfire-goal-item.goal-short {
  border-color: rgba(98, 226, 155, 0.5);
  background:
    linear-gradient(180deg, rgba(98, 226, 155, 0.14), rgba(255, 255, 255, 0.02)),
    rgba(255, 255, 255, 0.022);
}

.campfire-goal-item.goal-medium {
  border-color: rgba(255, 171, 74, 0.5);
  background:
    linear-gradient(180deg, rgba(255, 171, 74, 0.14), rgba(255, 255, 255, 0.02)),
    rgba(255, 255, 255, 0.022);
}

.campfire-goal-item.goal-long {
  border-color: rgba(158, 110, 255, 0.52);
  background:
    linear-gradient(180deg, rgba(158, 110, 255, 0.15), rgba(255, 255, 255, 0.02)),
    rgba(255, 255, 255, 0.022);
}

.campfire-goal-item.secret {
  border-color: rgba(255, 168, 72, 0.32);
  background:
    linear-gradient(180deg, rgba(255, 168, 72, 0.08), rgba(255, 255, 255, 0.02)),
    rgba(255, 255, 255, 0.018);
}

.campfire-goal-copy {
  display: grid;
  gap: 8px;
}

.campfire-goal-copy p {
  margin: 0;
  color: rgba(243, 234, 216, 0.82);
  line-height: 1.45;
  font-size: 0.92rem;
}

.campfire-secret-chip {
  color: #7d4413;
  border-color: rgba(255, 168, 72, 0.42);
  background: linear-gradient(180deg, rgba(255, 224, 178, 0.98), rgba(255, 192, 110, 0.9));
}

.campfire-gallery {
  display: grid;
  gap: 14px;
}

.hero-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid rgba(231, 197, 123, 0.22);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at top right, rgba(255, 148, 72, 0.1), transparent 30%),
    linear-gradient(180deg, rgba(18, 19, 18, 0.98), rgba(13, 15, 14, 0.92));
}

.hero-card.active {
  border-color: rgba(126, 255, 227, 0.34);
  box-shadow: 0 26px 84px rgba(0, 0, 0, 0.42), 0 0 0 1px rgba(126, 255, 227, 0.08);
}

.hero-card > header {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.hero-avatar {
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(231, 197, 123, 0.28);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 168, 72, 0.18), rgba(255, 255, 255, 0.04)),
    rgba(18, 20, 19, 0.96);
  color: #fff3d2;
  font-family: var(--font-display);
  font-size: 1.22rem;
  font-weight: 800;
  letter-spacing: 0;
}

.hero-avatar.has-image {
  padding: 0;
  overflow: hidden;
}

.hero-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.hero-headline h3 {
  margin: 0;
  color: #fff6de;
  font-family: var(--font-display);
  font-size: 1.18rem;
}

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

.hero-goal-column {
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(231, 197, 123, 0.14);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.022);
}

.hero-goal-column.goal-short {
  border-color: rgba(98, 226, 155, 0.5);
  background:
    linear-gradient(180deg, rgba(98, 226, 155, 0.14), rgba(255, 255, 255, 0.02)),
    rgba(255, 255, 255, 0.022);
}

.hero-goal-column.goal-medium {
  border-color: rgba(255, 171, 74, 0.5);
  background:
    linear-gradient(180deg, rgba(255, 171, 74, 0.14), rgba(255, 255, 255, 0.02)),
    rgba(255, 255, 255, 0.022);
}

.hero-goal-column.goal-long {
  border-color: rgba(158, 110, 255, 0.52);
  background:
    linear-gradient(180deg, rgba(158, 110, 255, 0.15), rgba(255, 255, 255, 0.02)),
    rgba(255, 255, 255, 0.022);
}

.hero-goal-column-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 10px;
}

.hero-goal-column-head strong {
  color: #fff5dc;
  font-size: 0.9rem;
}

.hero-goal-column-head span {
  color: rgba(243, 234, 216, 0.62);
  font-family: var(--font-mono);
  font-size: 0.74rem;
}

.hero-goal-items {
  display: grid;
  gap: 8px;
}

.hero-goal-chip {
  display: grid;
  gap: 6px;
  padding: 10px 11px;
  border: 1px solid rgba(231, 197, 123, 0.14);
  border-radius: 8px;
  background: rgba(10, 12, 11, 0.42);
}

.hero-goal-chip.goal-short {
  border-color: rgba(98, 226, 155, 0.5);
}

.hero-goal-chip.goal-medium {
  border-color: rgba(255, 171, 74, 0.5);
}

.hero-goal-chip.goal-long {
  border-color: rgba(158, 110, 255, 0.52);
}

.hero-goal-chip span {
  color: rgba(247, 235, 210, 0.88);
  font-size: 0.9rem;
  line-height: 1.35;
}

.hero-goal-chip em {
  color: rgba(255, 197, 113, 0.86);
  font-style: normal;
  font-size: 0.68rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero-goal-chip.secret {
  border-color: rgba(255, 168, 72, 0.3);
  background:
    linear-gradient(180deg, rgba(255, 168, 72, 0.08), rgba(255, 255, 255, 0.02)),
    rgba(10, 12, 11, 0.52);
}

.hero-goal-empty {
  padding: 10px 12px;
  border: 1px dashed rgba(231, 197, 123, 0.18);
  border-radius: 8px;
  color: rgba(243, 234, 216, 0.54);
  font-size: 0.82rem;
}

.campfire-goal-composer {
  margin-top: 18px;
}

.campfire-notes {
  margin-top: 16px;
}

.campfire-notes textarea {
  min-height: 180px;
}

.campfire-note-summary,
.campfire-goal-empty,
.hero-goal-empty {
  word-break: break-word;
}

.campfire-intro .chip-row {
  justify-content: flex-end;
}

.view.active .metric,
.view.active .panel,
.view.active .room-card,
.view.active .npc-card,
.view.active .market-card,
.view.active .source-card,
.view.active .hero-card,
.view.active .campfire-lane {
  animation: riseIn 520ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.view.active .calendar-month,
.view.active .calendar-entry {
  animation: riseIn 520ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.view.active .metric:nth-child(2),
.view.active .market-card:nth-child(2),
.view.active .npc-card:nth-child(2),
.view.active .room-card:nth-child(2),
.view.active .hero-card:nth-child(2),
.view.active .campfire-lane:nth-child(2) {
  animation-delay: 60ms;
}

.view.active .metric:nth-child(3),
.view.active .market-card:nth-child(3),
.view.active .npc-card:nth-child(3),
.view.active .room-card:nth-child(3),
.view.active .hero-card:nth-child(3),
.view.active .campfire-lane:nth-child(3) {
  animation-delay: 120ms;
}

.view.active .metric:nth-child(4),
.view.active .market-card:nth-child(4) {
  animation-delay: 180ms;
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 860px) {
  .workspace {
    padding: 22px 18px 44px;
  }

  .topbar h1 {
    font-size: 2.75rem;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid rgba(208, 164, 88, 0.34);
  }

  .nav-button:hover,
  .nav-button.active {
    transform: translateY(-1px);
  }

  .campfire-layout,
  .hero-card > header,
  .hero-goal-columns,
  .campfire-goal-columns {
    grid-template-columns: 1fr;
  }

  .hero-card > header {
    align-items: start;
  }
}

@media (max-width: 560px) {
  body {
    font-size: 16px;
  }

  .topbar h1 {
    font-size: 2.35rem;
  }

  .day-control {
    align-items: stretch;
  }

  .metric {
    min-height: 106px;
  }
}

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

.date-fields {
  display: grid;
  grid-template-columns: 78px minmax(128px, 1fr);
  gap: 8px;
  width: 100%;
}

.calendar-date-control {
  min-width: min(420px, 100%);
}

.calendar-date-control label {
  min-width: 250px;
}

.day-control input {
  width: 100%;
}

.inline-form {
  grid-template-columns: minmax(180px, 1fr) 140px 130px minmax(220px, 0.8fr) auto;
}

.inline-date {
  align-self: stretch;
}

.image-preview {
  min-height: 92px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px dashed rgba(208, 164, 88, 0.34);
  border-radius: var(--radius);
  color: rgba(243, 234, 216, 0.56);
  background:
    linear-gradient(135deg, rgba(208, 164, 88, 0.08), transparent),
    rgba(5, 7, 6, 0.42);
}

.image-preview img {
  width: 100%;
  height: 168px;
  object-fit: cover;
}

.room-image {
  width: 100%;
  height: 164px;
  margin: 0 0 12px;
  border: 1px solid rgba(208, 164, 88, 0.22);
  border-radius: calc(var(--radius) - 1px);
  object-fit: cover;
  filter: saturate(0.9) contrast(1.05);
}

.calendar-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
}

.calendar-controls {
  margin-bottom: 16px;
}

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

.auto-process {
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid rgba(208, 164, 88, 0.24);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.025);
  white-space: nowrap;
}

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

.calendar-month {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.065), rgba(255, 255, 255, 0.018)),
    rgba(18, 21, 18, 0.86);
  box-shadow: var(--shadow);
}

.calendar-month::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 229, 169, 0.48), transparent);
}

.calendar-month > header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  padding: 16px 16px 10px;
  border-bottom: 1px solid rgba(208, 164, 88, 0.16);
}

.calendar-month h3 {
  margin: 0;
  color: #fff5dc;
  font-family: var(--font-display);
  font-size: 1.18rem;
}

.calendar-month header span {
  color: rgba(243, 234, 216, 0.56);
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.calendar-entry-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.calendar-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 13px;
  border: 1px solid rgba(208, 164, 88, 0.18);
  border-radius: var(--radius);
  background: rgba(5, 7, 6, 0.34);
}

.calendar-entry.pending {
  border-color: rgba(208, 164, 88, 0.48);
  background: rgba(94, 62, 14, 0.18);
}

.calendar-entry.income {
  box-shadow: inset 3px 0 0 rgba(112, 214, 163, 0.72);
}

.calendar-entry.expense {
  box-shadow: inset 3px 0 0 rgba(255, 139, 114, 0.72);
}

.calendar-entry h4 {
  margin: 3px 0 0;
  color: #fff7e2;
  font-size: 1rem;
}

.calendar-entry p {
  margin: 6px 0 0;
  color: rgba(243, 234, 216, 0.64);
}

.calendar-date {
  color: var(--brass);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 800;
}

@media (max-width: 1180px) {
  .calendar-layout,
  .calendar-months {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .inline-form {
    grid-template-columns: 1fr;
  }

  .calendar-date-control label {
    min-width: 0;
  }

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

@media (max-width: 1280px) {
  .calendar-mini {
    grid-template-columns: repeat(8, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .calendar-mini {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .calendar-mini {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .date-fields {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .auto-process {
    white-space: normal;
  }

  .calendar-entry {
    grid-template-columns: 1fr;
  }

  .campfire-intro .chip-row {
    justify-content: flex-start;
  }

  .hero-card > header {
    grid-template-columns: 1fr;
  }

  .hero-avatar {
    width: 58px;
    height: 58px;
  }
}
