:root {
  color-scheme: light;
  --paper: #f6f7f2;
  --panel: #fff;
  --ink: #192c27;
  --muted: #536761;
  --line: #dbe4df;
  --brand: #174b3e;
  --brand-dark: #10382e;
  --pale: #e8f2eb;
  --alert: #973826;
  font: 16px/1.5 "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
a { color: inherit; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
:focus-visible { outline: 3px solid #32866c; outline-offset: 3px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(2.65rem, 6vw, 4.2rem); line-height: 1.12; letter-spacing: -.05em; font-weight: 700; }
h2 { font-size: 1.4rem; line-height: 1.25; letter-spacing: -.027em; }
.frame { width: min(100% - 3rem, 78rem); margin-inline: auto; }
.topbar { color: #fff; background: var(--brand-dark); }
.topbar-inner { min-height: 4.4rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { display: inline-flex; align-items: center; gap: .65rem; font-weight: 700; text-decoration: none; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 2rem; height: 2rem; border: 1px solid #80a799; border-radius: .5rem; }
.brand-mark::before { content: ''; width: 1rem; height: 1rem; border: 2px solid #c5e0a6; border-radius: 50%; background: radial-gradient(circle, #c5e0a6 29%, transparent 34%); }
nav { display: flex; align-items: center; gap: clamp(.8rem, 3vw, 1.8rem); }
nav a { color: #dfede6; font-size: .9rem; text-underline-offset: 4px; text-decoration: none; }
nav a:hover { text-decoration: underline; }
nav a[aria-current=page] { color: #fff; font-weight: 700; text-decoration: underline; text-underline-offset: .45rem; }
.topbar .signout { color: #fff; background: transparent; border-color: #649385; font-size: .85rem; }
.topbar .signout:hover { background: #245a4b; }
.button { min-height: 2.65rem; padding: .54rem .9rem; border: 1px solid transparent; border-radius: .55rem; line-height: 1.35; font-weight: 650; white-space: nowrap; }
.button.primary { color: #fff; background: var(--brand); border-color: var(--brand); }
.button.primary:hover { background: var(--brand-dark); }
.button.primary span { font-size: 1.13em; }
.outline { color: var(--brand); border-color: #b9ccc3; background: var(--panel); }
.outline:hover { background: var(--pale); }
.link-button { padding: .26rem .2rem; background: transparent; color: var(--brand); border: 0; text-decoration: underline; text-underline-offset: 4px; font-size: .88rem; }
.status { position: sticky; top: .65rem; z-index: 2; display: table; margin: 1.25rem 0 0; padding: .6rem .85rem; border: 1px solid #c6dacf; border-radius: .55rem; color: var(--brand); background: var(--pale); }
.status.error { border-color: #ecd0c9; background: #fff3ef; color: var(--alert); }
#retry { margin-top: 1rem; }
.workspace-page { padding: 2.8rem 0 4rem; }
.heading { display: flex; align-items: end; justify-content: space-between; gap: 1.3rem; margin-bottom: 2rem; }
.heading p, .panel-heading p, .muted { color: var(--muted); }
.heading p { margin-top: .55rem; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem; }
.report-controls { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; margin-bottom: .85rem; }
.report-controls label { display: inline; font-size: .9rem; }
.report-controls input { min-height: 2.2rem; width: auto; padding: .28rem .5rem; font-size: .9rem; }
.metrics { display: grid; grid-template-columns: 1.2fr repeat(3, 1fr); gap: .85rem; margin: 0 0 1.5rem; }
.metric { min-width: 0; min-height: 8rem; padding: 1rem 1.1rem; border-radius: .75rem; border: 1px solid var(--line); background: var(--panel); }
.metric div { color: var(--muted); font-size: .91rem; font-weight: 600; }
.metric strong { display: block; margin-top: .35rem; font-size: clamp(1.2rem, 2.5vw, 2.05rem); line-height: 1.22; font-variant-numeric: tabular-nums; letter-spacing: -.035em; overflow-wrap: anywhere; }
.metric-total { background: var(--brand); color: white; border-color: var(--brand); }
.metric-total div { color: #d4e8dc; }
.metric small { display: block; margin-top: .55rem; color: var(--muted); }
.metric-total small { color: #d4e8dc; }
.metrics-three { grid-template-columns: 1.2fr 1fr 1fr; }
.overview-total { padding: clamp(1.2rem, 4vw, 2.35rem); border-radius: 1rem; background: var(--brand); color: #fff; }
.overview-total p { color: #dbebe3; }
.overview-total strong { display: block; margin: .25rem 0; font-size: clamp(2.1rem, 7vw, 4.5rem); letter-spacing: -.045em; line-height: 1.12; overflow-wrap: anywhere; }
.overview-total #asset-warning { margin-top: .6rem; }
.asset-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: .85rem; margin: 1rem 0; }
.asset-card { display: grid; gap: .45rem; padding: 1.1rem; border-radius: .75rem; text-decoration: none; background: var(--panel); border: 1px solid var(--line); }
.asset-card:hover { border-color: #78a897; }
.asset-card span, .asset-rule { color: var(--muted); }
.asset-card strong { font-size: clamp(1.16rem, 3vw, 1.7rem); overflow-wrap: anywhere; }
.asset-share { display: flex; align-items: center; gap: .55rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.asset-share small { min-width: 4ch; text-align: right; white-space: nowrap; }
.asset-card progress { display: block; width: 100%; height: .48rem; border: 0; border-radius: 1rem; background: #e9efe9; accent-color: #367864; }
.asset-card progress::-webkit-progress-bar { border-radius: 1rem; background: #e9efe9; }
.asset-card progress::-webkit-progress-value { border-radius: 1rem; background: #367864; }
.gold-accent progress { accent-color: #927332; }
.gold-accent progress::-webkit-progress-value { background: #927332; }
.asset-rule { font-size: .9rem; }
.inline-warning { margin: 0 0 1rem; padding: .65rem .85rem; border-radius: .45rem; background: #faf0d6; color: #664913; }
.chart-wrap { padding: .3rem 1rem .8rem; }
.chart-legend { display: flex; align-items: center; gap: 1rem; padding: 0 .45rem; color: var(--muted); font-size: .89rem; }
.chart-legend i { display: inline-block; width: .85rem; height: .22rem; margin: 0 .35rem .18rem 0; background: #147456; }
.chart-legend span + span i { background: #9a7328; }
#performance-canvas { display: block; width: 100%; height: clamp(13rem, 31vw, 20rem); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: .8rem; }
.table-panel + .table-panel { margin-top: 1.15rem; }
.panel-heading { min-height: 5rem; display: flex; align-items: center; justify-content: space-between; gap: .8rem 1rem; padding: 1.05rem 1.2rem; }
.panel-heading p { margin-top: .2rem; font-size: .9rem; }
.select-label { display: flex; align-items: center; gap: .5rem; font-size: .89rem; white-space: nowrap; }
.table-scroll { position: relative; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: .94rem; }
th, td { padding: .78rem .9rem; vertical-align: middle; }
th:first-child, td:first-child { padding-left: 1.2rem; }
th:last-child, td:last-child { padding-right: 1.2rem; }
th { background: #edf2ee; color: #365047; font-weight: 650; font-size: .85rem; white-space: nowrap; }
tbody tr + tr { border-top: 1px solid #edf1ee; }
tbody tr:hover { background: #fafcf9; }
td small { display: block; color: var(--muted); font-size: .85rem; }
.number { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.chip { display: inline-block; padding: .2rem .55rem; white-space: nowrap; font-weight: 600; font-size: .83rem; border-radius: 2rem; color: #225341; background: var(--pale); }
.chip.closed { color: #53645c; background: #eff1ef; }
.chip.due { color: #6c4d17; background: #f9edce; }
.cell-action { padding: 0; text-align: left; }
.positive { color: #1a694e; }
.negative { color: var(--alert); }
.empty { padding: 1.15rem 1.2rem 1.5rem; color: var(--muted); border-top: 1px solid var(--line); }
.panel-footer { padding: .85rem 1.2rem; border-top: 1px solid var(--line); }
.error { color: var(--alert); }
.login { min-height: min(72vh, 43rem); display: grid; grid-template-columns: 1fr minmax(19rem, 27rem); gap: 3rem; align-items: center; max-width: 66rem; margin: auto; padding-block: 2rem; }
.login-copy p { color: var(--muted); margin-top: .9rem; max-width: 30rem; }
.login-form { display: grid; gap: 1rem; padding: clamp(1.2rem, 4vw, 2rem); }
label { display: grid; gap: .32rem; font-weight: 600; }
input, textarea, select { width: 100%; min-height: 2.65rem; padding: .5rem .65rem; border: 1px solid #bccdc4; border-radius: .45rem; background: #fff; color: var(--ink); font-weight: 400; }
select { appearance: none; padding-right: 1.8rem; min-width: 8rem; background: linear-gradient(45deg, transparent 50%, var(--muted) 50%) right .85rem top 50% / .3rem .3rem no-repeat, linear-gradient(135deg, var(--muted) 50%, transparent 50%) right .55rem top 50% / .3rem .3rem no-repeat, #fff; }
textarea { resize: vertical; }
input[type=file] { padding: .45rem; }
dialog { width: min(100% - 1.5rem, 35rem); max-height: calc(100% - 2rem); border: 1px solid var(--line); padding: 0; border-radius: .95rem; color: var(--ink); background: var(--panel); box-shadow: 0 1rem 4rem #152c2840; }
dialog::backdrop { background: #14282395; }
.dialog-form { display: grid; gap: 1.15rem; padding: clamp(1rem, 4vw, 1.55rem); }
#market-dialog { width: min(100% - 1.5rem, 41rem); }
.market-details summary { cursor: pointer; font-weight: 600; color: var(--brand); }
.market-details .form-grid { margin-top: .6rem; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.close { width: 2.25rem; height: 2.25rem; border: 0; border-radius: .4rem; color: var(--muted); background: #f0f4f1; font-size: 1.5rem; line-height: 1; }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .8rem; }
.wide { grid-column: 1 / -1; }
.field-optional { display: contents; font-weight: 400; }
.callout, .import-preview { padding: .7rem .85rem; border-radius: .55rem; color: var(--brand); background: var(--pale); }
.callout { display: flex; justify-content: space-between; gap: .5rem; }
.dialog-actions { display: flex; justify-content: end; gap: .55rem; }
.import-preview dl { display: grid; grid-template-columns: minmax(0, 1fr) auto; margin: .4rem 0 0; gap: .2rem .75rem; }
.import-preview dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

@media (max-width: 800px) {
  .metrics { grid-template-columns: 1fr 1fr; }
  .panel-heading { align-items: start; }
  .login { grid-template-columns: 1fr; gap: 1.4rem; min-height: auto; align-items: start; max-width: 30rem; }
}
@media (max-width: 530px) {
  .frame { width: calc(100% - 1.5rem); }
  .topbar-inner { min-height: 3.65rem; flex-wrap: wrap; gap: 0 .65rem; padding-block: .43rem; }
  nav { order: 3; width: 100%; padding: .3rem 0 .52rem; justify-content: space-between; gap: .28rem; white-space: nowrap; overflow-x: auto; }
  nav a { font-size: .82rem; }
  .asset-cards { grid-template-columns: 1fr; }
  .heading, .panel-heading { align-items: start; flex-direction: column; }
  .workspace-page { padding-top: 1.7rem; }
  .metric { min-height: 6rem; padding: .8rem; }
  .metric strong { font-size: 1.28rem; }
  .panel-heading { padding: .95rem .95rem; }
}
@media (max-width: 350px) {
  .form-grid { grid-template-columns: 1fr; }
}
