:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #202421;
  --muted: #6b736e;
  --line: #dfe4dd;
  --accent: #1f7a5b;
  --accent-dark: #155a43;
  --warn: #a85d12;
  --bad: #b43232;
  --good-bg: #e4f4ec;
  --warn-bg: #fff0dc;
  --bad-bg: #f9e4e4;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(20px, 4vw, 48px);
  background:
    linear-gradient(180deg, #18372f 0, #18372f 34%, #eef2ee 34%, #eef2ee 100%);
}

.login-shell {
  width: min(460px, 100%);
  display: grid;
  gap: 18px;
}

.login-brand {
  color: white;
  text-align: center;
}

.login-brand h1 {
  margin-top: 6px;
  font-size: clamp(30px, 5vw, 42px);
}

.login-panel {
  display: grid;
  gap: 18px;
  padding: clamp(24px, 5vw, 34px);
  border: 1px solid #d8e0da;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 22px 55px rgba(24, 55, 47, 0.18);
}

.login-heading {
  padding-bottom: 4px;
}

.login-heading h2 {
  margin: 0;
  color: var(--ink);
  font-size: 1.65rem;
  line-height: 1.1;
}

.login-panel label {
  display: grid;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 700;
}

.login-panel input {
  width: 100%;
  border: 1px solid #c9d6cf;
  border-radius: 6px;
  background: #fbfcfb;
  padding: 13px 12px;
  font: inherit;
}

.login-panel input:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(31, 122, 91, 0.14);
}

.login-panel button {
  border: 0;
  border-radius: 6px;
  min-height: 46px;
  padding: 0 14px;
  background: var(--accent-dark);
  color: #ffffff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.login-panel button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.form-error {
  min-height: 1.2em;
  margin: 0;
  color: var(--bad);
  font-weight: 700;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px clamp(18px, 4vw, 48px);
  background: #18372f;
  color: white;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08) inset;
}

.topbar-title {
  min-width: 240px;
}

.eyebrow {
  margin: 0 0 4px;
  color: #a6d8c1;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.05;
  letter-spacing: 0;
}

main {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 24px clamp(14px, 3vw, 32px) 48px;
}

.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  background: #ffffff;
  color: #18372f;
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.file-button:hover {
  background: #eef5f1;
}

.topbar .file-button {
  border-color: transparent;
}

.detail-actions .secondary-button,
.detail-actions .file-button {
  min-height: 34px;
  padding: 0 11px;
  border-color: #d7e1dc;
  background: #ffffff;
  color: var(--ink);
  font-size: 13px;
  line-height: 1;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.detail-actions .secondary-button:hover,
.detail-actions .file-button:hover {
  border-color: var(--accent);
  background: #f7fbf8;
  color: var(--accent-dark);
}

.detail-actions .primary-secondary-button {
  border-color: #1f6f53;
  background: #1f6f53;
  color: white;
  box-shadow: none;
}

.detail-actions .primary-secondary-button:hover {
  background: var(--accent-dark);
  color: white;
}

.detail-actions .danger-secondary-button {
  border-color: #ead0cb;
  background: #ffffff;
  color: #8b372d;
}

.detail-actions .danger-secondary-button:hover {
  border-color: #d39c93;
  background: #feece8;
  color: #7e3027;
}

.secondary-button.danger-secondary-button {
  border-color: #e1c7c2;
  background: #fff7f5;
  color: #9a3f32;
}

.secondary-button.danger-secondary-button:hover {
  border-color: #d39c93;
  background: #feece8;
  color: #7e3027;
}

.detail-actions .favorite-detail-button.active,
.favorite-button.active,
.filter-toggle.active {
  border-color: #d6a918;
  background: #fff4c7;
  color: #6d5100;
}

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

.action-group,
.account-menu {
  display: inline-flex;
  align-items: center;
  min-height: 46px;
  border-radius: 8px;
}

.action-group {
  gap: 2px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.08);
}

.account-menu {
  gap: 10px;
  padding: 4px 4px 4px 10px;
  background: rgba(0, 0, 0, 0.15);
}

.account-link {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding-right: 4px;
  border-radius: 999px;
  color: inherit;
  text-decoration: none;
}

.account-link:hover .account-badge {
  color: #ffffff;
}

.account-avatar {
  display: inline-grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 999px;
  background: #e4f4ec;
  color: var(--accent-dark);
  font-size: 0.85rem;
  font-weight: 700;
}

.account-badge {
  max-width: 180px;
  overflow: hidden;
  font-size: 0.85rem;
  font-weight: 800;
  color: #cfe9dc;
  text-overflow: ellipsis;
  white-space: nowrap;
}

[hidden] {
  display: none !important;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: white;
  font-size: 0.9rem;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.1);
}

.button-link {
  font: inherit;
  cursor: pointer;
  background: transparent;
  color: #dbeee5;
}

.button-link:hover {
  color: #ffffff;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.assumptions,
.summary,
.toolbar {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.assumptions {
  grid-template-columns: repeat(5, minmax(130px, 1fr));
}

.assumption-card,
.summary article {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.assumption-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
}

.assumption-card strong {
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  font: inherit;
}

.summary {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
}

.summary article {
  padding: 14px;
}

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

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

.toolbar {
  grid-template-columns: 1fr 200px 200px 190px 130px 160px;
}

.toolbar input,
.toolbar select,
.toolbar button {
  padding: 0 12px;
}

.toolbar button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.toolbar button:hover {
  background: var(--accent-dark);
}

.toolbar .filter-toggle {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
}

.toolbar .filter-toggle:hover {
  border-color: #d6a918;
  background: #fff9df;
  color: #6d5100;
}

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.secondary-button:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.hidden-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef2ee;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.sort-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 800;
  text-transform: inherit;
  cursor: pointer;
}

.sort-button::after {
  content: "↕";
  color: #98a19b;
  font-size: 11px;
}

.sort-button.active[data-direction="asc"]::after {
  content: "↑";
  color: var(--accent-dark);
}

.sort-button.active[data-direction="desc"]::after {
  content: "↓";
  color: var(--accent-dark);
}

.favorite-button {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: #9aa39d;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.favorite-button:hover {
  border-color: #d6a918;
  background: #fff9df;
  color: #8a6700;
}

td {
  font-size: 14px;
}

.object-title {
  max-width: 390px;
  font-weight: 800;
  line-height: 1.35;
}

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

.money,
.number {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.positive {
  color: var(--accent-dark);
  font-weight: 800;
}

.negative {
  color: var(--bad);
  font-weight: 800;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.good {
  background: var(--good-bg);
  color: var(--accent-dark);
}

.badge.warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.badge.bad {
  background: var(--bad-bg);
  color: var(--bad);
}

.content-page {
  max-width: 1120px;
}

.admin-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 18px;
}

.admin-panel + .admin-panel {
  margin-top: 18px;
}

.admin-upload {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.admin-upload button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  padding: 0 16px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.admin-upload button:hover {
  background: var(--accent-dark);
}

.admin-file-list {
  display: grid;
  gap: 10px;
}

.admin-file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
}

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

.admin-file-row span,
.admin-empty {
  color: var(--muted);
  font-size: 13px;
}

.admin-row-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.history-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 10px;
  margin: 14px 0 18px;
}

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

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

.history-summary strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.history-grid h3,
.admin-panel > section h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.history-list {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
}

.history-row strong {
  display: block;
  font-size: 13px;
}

.shared-section {
  display: grid;
  gap: 10px;
}

.shared-section h3 {
  margin: 8px 0 0;
  font-size: 15px;
}

.share-dialog {
  width: min(620px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: #ffffff;
  color: var(--text);
  box-shadow: 0 24px 80px rgba(18, 31, 28, 0.24);
}

.share-dialog::backdrop {
  background: rgba(12, 20, 18, 0.45);
}

.share-dialog form {
  display: grid;
  gap: 0;
}

.share-dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 22px 16px;
  border-bottom: 1px solid var(--line);
}

.share-dialog-heading h3 {
  margin: 2px 0 6px;
  font-size: 22px;
  line-height: 1.15;
}

.share-dialog-heading p:last-child {
  margin: 0;
  max-width: 420px;
  color: var(--muted);
  font-size: 14px;
}

.share-user-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
  max-height: 360px;
  overflow: auto;
  padding: 18px 22px;
  background: #f7faf8;
}

.share-user-list .admin-empty {
  grid-column: 1 / -1;
  margin: 0;
  padding: 14px;
  border: 1px dashed #cfdcd5;
  border-radius: 8px;
  background: #ffffff;
}

.share-user-option {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 62px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.share-user-option:hover {
  border-color: #b9d3c6;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
}

.share-user-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.share-user-check {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  border: 1px solid #bdd0c7;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: inset 0 0 0 4px #ffffff;
}

.share-user-option:has(input:checked) {
  border-color: #1f6f53;
  background: #eef7f2;
  box-shadow: 0 0 0 3px rgba(31, 111, 83, 0.12);
}

.share-user-option:has(input:checked) .share-user-check {
  border-color: #1f6f53;
  background: #1f6f53;
}

.share-user-copy,
.share-user-copy strong,
.share-user-copy small {
  display: block;
}

.share-user-copy strong {
  margin-bottom: 3px;
  font-size: 14px;
}

.share-user-copy small {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.share-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 22px 20px;
  border-top: 1px solid var(--line);
}

.share-dialog-actions button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  padding: 0 16px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.share-dialog-actions button:hover {
  background: var(--accent-dark);
}

.share-dialog-actions .secondary-button {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
}

.share-dialog-actions .secondary-button:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.market-page {
  display: grid;
  gap: 18px;
}

.market-hero,
.market-note,
.market-quality,
.market-panel,
.market-category-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.market-hero,
.market-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.market-hero {
  padding: 18px;
}

.market-hero h2 {
  margin-bottom: 0;
}

.market-note,
.market-quality {
  padding: 14px 16px;
}

.market-note span,
.market-quality span {
  color: var(--muted);
  line-height: 1.45;
}

.market-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 240px)) max-content;
  gap: 12px;
  align-items: end;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.market-filters label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.market-filters select {
  padding: 0 12px;
}

.market-summary {
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  margin-bottom: 0;
}

.market-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(520px, 1fr));
  gap: 18px;
}

.market-panel {
  min-width: 0;
  padding: 18px;
}

.market-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.market-table {
  min-width: 980px;
}

.market-histogram {
  min-height: 380px;
}

.histogram-plot {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 12px;
  min-height: 390px;
}

.histogram-y-axis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding-bottom: 96px;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.histogram-chart {
  display: grid;
  grid-template-rows: 1fr auto;
  min-width: 0;
}

.histogram-bars {
  display: block;
  width: 100%;
  height: 280px;
  border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(to top, transparent calc(50% - 1px), #edf2ee calc(50% - 1px), #edf2ee 50%, transparent 50%),
    linear-gradient(to top, transparent calc(100% - 1px), #edf2ee calc(100% - 1px));
}

.histogram-bar {
  fill: var(--accent);
}

.histogram-x-axis {
  display: grid;
  grid-template-columns: repeat(15, minmax(0, 1fr));
  gap: 4px;
  min-height: 96px;
  padding: 10px 0 0 4px;
  color: var(--muted);
  font-size: 10px;
}

.histogram-x-axis span {
  justify-self: end;
  width: max-content;
  max-width: 72px;
  transform: rotate(-45deg);
  transform-origin: top right;
  overflow-wrap: normal;
  text-align: right;
  line-height: 1.15;
  white-space: nowrap;
}

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

.market-category-card {
  padding: 12px;
  background: #fbfdfb;
}

.market-category-card strong,
.market-category-card span {
  display: block;
}

.market-category-card span {
  color: var(--muted);
  font-size: 12px;
}

.market-category-card dl {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0 0;
}

.market-category-card dt {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.market-category-card dd {
  color: var(--ink);
  font-weight: 800;
}

.explain-section {
  padding: 8px 0 28px;
  border-bottom: 1px solid var(--line);
}

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

h2 {
  margin: 0 0 16px;
  font-size: 24px;
  letter-spacing: 0;
}

h3 {
  margin: 0 0 8px;
  font-size: 16px;
  letter-spacing: 0;
}

.definition-grid,
.formula-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 12px;
}

.definition-grid {
  margin: 0;
}

.definition-grid div,
.formula-list article,
.logic-list p {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

dt {
  margin-bottom: 6px;
  font-weight: 800;
}

dd,
.formula-list p,
.logic-list p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.formula-list code {
  display: inline-block;
  margin-bottom: 8px;
  padding: 4px 7px;
  border-radius: 5px;
  background: #eef2ee;
  color: var(--ink);
  font-size: 13px;
  white-space: normal;
}

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

.logic-list strong {
  color: var(--ink);
}

.detail-page {
  width: min(1480px, 100%);
  max-width: 1480px;
  margin: 0 auto;
}

.account-page {
  display: grid;
  gap: 18px;
  width: min(1100px, 100%);
}

.account-panel {
  display: grid;
  gap: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: clamp(18px, 3vw, 28px);
}

.account-panel h2 {
  margin: 0;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.1;
}

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

.settings-grid label {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.settings-grid label span {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-weight: 800;
}

.settings-grid input {
  min-height: 38px;
  padding: 0 10px;
  font-weight: 800;
}

.settings-grid input:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(31, 122, 91, 0.14);
}

.settings-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 4px;
}

.settings-actions button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  padding: 0 16px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.settings-actions button:hover {
  background: var(--accent-dark);
}

.detail-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.detail-actions {
  display: grid;
  gap: 8px;
  justify-content: flex-end;
  justify-items: end;
  max-width: min(760px, 100%);
}

.detail-action-group {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-height: 40px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbf9;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.detail-action-group-primary {
  background: #ffffff;
  border-color: #d8e5de;
}

.detail-action-group-object {
  justify-self: end;
}

.detail-action-group .status-pill {
  min-height: 28px;
  margin: 0 4px 0 3px;
  padding: 5px 9px;
  font-size: 12px;
  white-space: nowrap;
}

.detail-hero h2 {
  max-width: 880px;
  margin-bottom: 0;
  line-height: 1.14;
}

.shared-calculation-notice {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  width: fit-content;
  max-width: 760px;
  margin-top: 10px;
  padding: 9px 12px;
  border: 1px solid #b8d2c6;
  border-left: 4px solid #1f6f53;
  border-radius: 8px;
  background: #eef7f2;
  color: #1d4f3d;
  font-size: 13px;
  line-height: 1.35;
}

.shared-calculation-notice[hidden] {
  display: none;
}

.shared-calculation-notice strong {
  color: #173f31;
  font-size: 12px;
  text-transform: uppercase;
}

.image-gallery-panel {
  margin: 18px 0 20px;
}

.image-gallery {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 12px;
  min-height: 320px;
}

.image-stage {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef2ee;
  aspect-ratio: 16 / 8;
}

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

.image-thumbnails {
  display: grid;
  grid-auto-rows: 86px;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
  padding-right: 2px;
}

.image-thumb {
  overflow: hidden;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 7px;
  background: #eef2ee;
  cursor: pointer;
}

.image-thumb.active {
  border-color: var(--accent);
}

.image-thumb-broken {
  display: none;
}

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

.image-gallery-empty {
  display: grid;
  place-items: center;
  min-height: 180px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--panel);
  font-weight: 700;
}

.warning {
  color: var(--warn);
  font-weight: 800;
}

.cockpit-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(300px, 1fr));
  align-items: start;
  gap: 14px;
}

.cockpit-column {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.cockpit-column > h2 {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 42px;
  margin: 0;
  padding: 0 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #eef2ee;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  text-align: left;
}

.cockpit-table {
  width: 100%;
  min-width: 0;
  margin: 0;
  border: 0;
  border-collapse: collapse;
  background: transparent;
  font-size: 12px;
  line-height: 1.3;
}

.cockpit-table th {
  position: static;
  padding: 10px 14px 6px;
  border: 0;
  background: transparent;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-align: left;
  text-transform: none;
}

.cockpit-table td {
  padding: 6px 14px;
  border: 0;
  border-top: 1px solid var(--line);
  color: var(--ink);
  font-size: 12px;
  vertical-align: middle;
}

.cockpit-table .value-cell {
  min-width: 74px;
  background: transparent;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-weight: 800;
}

.cockpit-input {
  width: 100%;
  min-width: 76px;
  min-height: 28px;
  padding: 3px 44px 3px 6px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: #eef5f1;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  text-align: right;
}

.cockpit-input.text-input {
  min-width: 120px;
  text-align: left;
  padding-right: 6px;
}

.cockpit-select {
  min-width: 116px;
  padding-right: 28px;
  cursor: pointer;
  text-align: left;
  appearance: auto;
}

.cockpit-input:focus {
  outline: 2px solid rgba(31, 122, 91, 0.22);
  border-color: var(--accent);
  background: white;
}

.input-wrap {
  position: relative;
  display: inline-flex;
  width: 100%;
  min-width: 86px;
  align-items: center;
}

.input-unit {
  position: absolute;
  right: 8px;
  min-width: 34px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-align: right;
  pointer-events: none;
}

.input-wrap:has(.cockpit-input.text-input):has(.input-unit) .cockpit-input {
  padding-right: 44px;
}

.cockpit-input::-webkit-outer-spin-button,
.cockpit-input::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
}


.cockpit-table .emphasis-row td {
  font-weight: 800;
  background: #f7faf8;
}

.cockpit-table .positive {
  color: var(--accent-dark);
  font-weight: 800;
}

.cockpit-table .negative {
  color: var(--bad);
  font-weight: 800;
}

.cockpit-table .spacer-row td {
  height: 6px;
  border: 0;
  background: transparent;
}

.description-panel {
  width: 100%;
  margin-top: 24px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.expose-panel {
  width: 100%;
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.panel-heading-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.compact-button {
  min-height: 32px;
  padding: 7px 10px;
  font-size: 12px;
}

.cashflow-threshold-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: 100%;
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.cashflow-threshold-panel h3 {
  margin: 0;
}

.market-context-panel {
  width: 100%;
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.market-context-summary {
  max-width: 980px;
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.55;
}

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

.market-context-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.market-context-kpi {
  display: grid;
  align-content: start;
  gap: 7px;
  min-height: 190px;
  padding: 13px;
  border: 1px solid #cfe0d4;
  border-radius: 8px;
  background: #f4faf5;
}

.market-context-kpi span,
.market-context-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.market-context-kpi strong {
  color: var(--ink);
  font-size: 18px;
  line-height: 1.25;
}

.market-context-kpi p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.market-context-kpi em {
  color: var(--accent-dark);
  font-size: 13px;
  font-style: normal;
  font-weight: 800;
  line-height: 1.4;
}

.market-context-kpi small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.market-context-kpi a {
  align-self: end;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.market-context-card {
  display: grid;
  gap: 6px;
  min-height: 118px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
}

.market-context-card strong {
  color: var(--ink);
  font-size: 16px;
}

.market-context-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.market-context-checks {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.market-context-checks h4 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 14px;
}

.market-context-checks ul {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.45;
}

.market-context-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.market-context-sources a {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.threshold-metric {
  display: grid;
  gap: 5px;
  justify-items: end;
  text-align: right;
}

.threshold-metric strong {
  color: var(--ink);
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1;
}

.threshold-metric span {
  font-size: 13px;
}

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

.panel-heading-row h3 {
  margin: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: #eef2ee;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.good {
  background: var(--good-bg);
  color: var(--accent-dark);
}

.status-pill.warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.expose-summary {
  display: grid;
  gap: 12px;
  color: var(--muted);
  line-height: 1.55;
}

.expose-summary h4 {
  margin: 4px 0 -4px;
  color: var(--ink);
  font-size: 14px;
}

.expose-summary dl {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 8px;
  margin: 0;
}

.expose-summary div {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfb;
}

.expose-summary dt {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
}

.expose-summary dd {
  margin: 0;
  color: var(--ink);
  font-weight: 800;
}

.expose-summary small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.expose-summary ul {
  margin: 0;
  padding-left: 18px;
}

.expose-warning {
  margin: 0;
  padding: 9px 11px;
  border: 1px solid #f0c36d;
  border-radius: 7px;
  background: var(--warn-bg);
  color: var(--warn);
  font-weight: 700;
}

.analysis-method {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--good-bg);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}

.description-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

@media (max-width: 980px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .login-shell {
    min-height: auto;
    grid-template-columns: 1fr;
  }

  .login-brand {
    min-height: 0;
  }

  .login-panel {
    justify-self: stretch;
    width: 100%;
    padding: 28px;
  }

  .assumptions {
    grid-template-columns: repeat(2, minmax(130px, 1fr));
  }

  .summary,
  .toolbar,
  .market-filters,
  .market-summary,
  .market-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

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

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

  .action-group,
  .account-menu,
  .settings-actions {
    flex-wrap: wrap;
  }

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

  .definition-grid,
  .formula-list {
    grid-template-columns: 1fr;
  }

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

  .detail-actions,
  .detail-action-group {
    width: 100%;
    justify-content: flex-start;
  }

  .detail-actions {
    justify-items: stretch;
  }

  .detail-action-group {
    overflow-x: auto;
  }

  .cashflow-threshold-panel {
    align-items: flex-start;
    flex-direction: column;
  }

  .threshold-metric {
    justify-items: start;
    text-align: left;
  }

  .image-gallery {
    grid-template-columns: 1fr;
  }

  .image-stage {
    aspect-ratio: 4 / 3;
  }

  .image-thumbnails {
    grid-template-columns: repeat(4, minmax(74px, 1fr));
    grid-auto-rows: 74px;
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  .detail-page {
    width: 100%;
  }

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

  .description-panel {
    width: 100%;
  }

  .expose-summary dl {
    grid-template-columns: 1fr;
  }
}
