:root {
  --ink: #17231d;
  --muted: #66736c;
  --paper: #eaf1ee;
  --panel: rgba(255, 255, 255, .76);
  --line: #dce2dd;
  --glass-line: rgba(255, 255, 255, .82);
  --accent: #167d63;
  --accent-dark: #0c5945;
  --control-line: #c7d0c9;
  --subtle: rgba(246, 248, 246, .78);
  --danger: #a43d35;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--ink); background: radial-gradient(circle at 14% 6%, rgba(83, 184, 151, .14), transparent 34%), radial-gradient(circle at 86% 16%, rgba(93, 132, 190, .1), transparent 32%), linear-gradient(145deg, #edf5f1, #e9eef2 55%, #f3f6f3); background-attachment: fixed; line-height: 1.45; }
button, input, select, textarea { font: inherit; }
button { min-height: 40px; border: 1px solid transparent; border-radius: 7px; padding: .58rem .9rem; color: white; background: var(--accent); cursor: pointer; font-weight: 650; }
button:hover:not(:disabled) { background: var(--accent-dark); }
button:active:not(:disabled) { background: #094b3b; }
button:focus-visible { outline: 3px solid rgba(22, 125, 99, .2); outline-offset: 2px; }
button:disabled { opacity: .55; cursor: not-allowed; }
button.secondary { border-color: var(--line); color: var(--ink); background: white; }
button.secondary:hover:not(:disabled) { border-color: var(--control-line); background: var(--subtle); }
button.small { min-height: 32px; padding: .32rem .6rem; font-size: .82rem; }
button.danger { background: #f3dfdc; color: var(--danger); }
button.danger:hover:not(:disabled) { background: #ead0cc; }
[hidden] { display: none !important; }

.shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 24px 0 48px; }
.login-card { width: min(430px, 100%); margin: 12vh auto 0; padding: 32px; border: 1px solid var(--glass-line); border-radius: 12px; background: var(--panel); backdrop-filter: blur(16px) saturate(112%); box-shadow: 0 10px 30px rgba(23, 35, 29, .09); }
h1, h2 { margin: 0; letter-spacing: -.025em; }
h3 { margin: 0; }
h1 { font-size: clamp(1.65rem, 3vw, 2rem); line-height: 1.15; }
h2 { font-size: 1.25rem; line-height: 1.25; }
h3 { font-size: 1rem; line-height: 1.35; }
.muted { color: var(--muted); }
.stack { display: grid; gap: 16px; margin-top: 22px; }
label { display: grid; gap: 7px; color: #47534d; font-size: .82rem; font-weight: 700; }
input, select, textarea { width: 100%; min-height: 40px; border: 1px solid var(--control-line); border-radius: 7px; padding: .58rem .7rem; color: var(--ink); background: white; }
input:hover:not(:disabled), select:hover:not(:disabled), textarea:hover:not(:disabled) { border-color: #9daaa1; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(22, 125, 99, .16); border-color: var(--accent); }
input:disabled, select:disabled, textarea:disabled { color: var(--muted); background: #eef1ee; cursor: not-allowed; }
textarea { min-height: 76px; resize: vertical; }
.checkbox { display: flex; align-items: center; align-self: end; min-height: 40px; gap: 8px; }
.checkbox input, .choice-option input { width: 16px; min-height: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.choice-picker { min-width: 0; margin: 0; padding: 9px 11px 11px; border: 1px solid var(--control-line); border-radius: 7px; background: white; }
.choice-picker legend { padding: 0 4px; color: #47534d; font-size: .82rem; font-weight: 700; }
.choice-picker legend span { color: var(--muted); font-weight: 500; }
.choice-options { display: flex; flex-wrap: wrap; column-gap: 16px; row-gap: 7px; }
.choice-option { display: inline-flex; align-items: center; gap: 6px; padding: .25rem 0; color: var(--ink); cursor: pointer; font-weight: 500; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
.account { display: flex; align-items: center; gap: 14px; color: var(--muted); }
.tabs { display: flex; gap: 22px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.tab { flex: 0 0 auto; min-width: max-content; min-height: 38px; padding: .55rem .1rem; border-radius: 0; border-bottom: 2px solid transparent; color: var(--muted); background: transparent; }
.tab:hover:not(:disabled) { color: var(--ink); background: transparent; }
.tab.active { border-bottom-color: var(--accent); color: var(--ink); background: transparent; }
.panel { margin-top: 16px; padding: 24px; border: 1px solid var(--glass-line); border-radius: 10px; background: var(--panel); backdrop-filter: blur(14px) saturate(110%); box-shadow: 0 8px 24px rgba(23, 35, 29, .055); }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 18px; }
.metrics { display: grid; grid-template-columns: repeat(5, 1fr); overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--subtle); }
.metric { padding: 16px 18px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric strong { display: block; font-size: 1.65rem; line-height: 1.2; }
.metric span { color: var(--muted); font-size: .86rem; }
.overview-block { margin-top: 26px; }
.overview-block h3 { margin-bottom: 8px; }
.help-text { max-width: 860px; margin: 0 0 14px; color: var(--muted); font-size: .88rem; line-height: 1.5; }
.shortage { color: var(--danger); font-weight: 750; }
.inline-form { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 14px; margin: -2px 0 20px; padding: 18px 0; border-block: 1px solid var(--line); }
.inline-form.columns { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
.inline-form .wide { grid-column: span 2; }
.inline-form > button { align-self: end; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: white; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .91rem; }
th, td { padding: 10px 11px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; vertical-align: top; }
th { color: #52635a; background: var(--subtle); font-size: .76rem; line-height: 1.25; }
tbody tr:hover { background: #f7faf8; }
tbody tr:last-child td { border-bottom: 0; }
td { font-variant-numeric: tabular-nums; }
#deals-body td:nth-child(1), #deals-body td:nth-child(5), #deals-body td:nth-child(6), #deals-body td:nth-child(7), #deals-body td:nth-child(8), #finance-events-body td:nth-child(1), #finance-events-body td:nth-child(2), #finance-events-body td:nth-child(3), #finance-events-body td:nth-child(5), #finance-events-body td:nth-child(6), #profit-overview-body td, #city-overview-body td:nth-child(n+3), #cost-pools-body td:nth-child(n+3), #wallet-overview-body td:nth-child(2) { text-align: right; }
.status { display: inline-flex; padding: .22rem .45rem; border-radius: 5px; color: #176b4d; background: #e3f1e9; font-size: .78rem; font-weight: 700; }
.status.off { color: #706b68; background: #ecebea; }
.row-actions { min-width: 250px; white-space: nowrap; }
.row-actions > button { margin: 3px 4px 3px 0; }
.wallet-name { width: 180px; max-width: 180px; }
.wallet-name-text { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wallet-address { max-width: 250px; overflow-wrap: anywhere; white-space: normal; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.access-list { min-width: 250px; white-space: normal; }
.access-line { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 4px 0; }
.deal-history { margin-top: 6px; padding-top: 16px; border-top: 1px solid var(--line); }
.deal-history h3 { margin-bottom: 10px; font-size: 1rem; }
.deal-history pre { overflow-x: auto; white-space: pre-wrap; }
.history-entry { margin: 0; padding: 11px 0; border-bottom: 1px solid var(--line); }
.history-entry strong, .history-entry span { display: block; }
.history-entry span { margin-top: 4px; color: var(--muted); font-size: .82rem; white-space: normal; }
#target-sale-result, #profit-filter-result { white-space: pre-line; }
.empty { padding: 24px 10px; color: var(--muted); text-align: center; }
.toast { position: fixed; right: 20px; bottom: 20px; max-width: min(420px, calc(100% - 40px)); padding: 12px 16px; border-radius: 8px; color: white; background: var(--ink); box-shadow: 0 8px 24px rgba(0,0,0,.16); }
.toast.error { background: var(--danger); }

@media (max-width: 760px) {
  .shell { width: min(100% - 20px, 1180px); padding-top: 18px; }
  .topbar { align-items: flex-start; }
  .account { align-items: flex-end; flex-direction: column; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metric { border-bottom: 1px solid var(--line); }
  .metric:nth-child(2n) { border-right: 0; }
  .metric:last-child { grid-column: 1 / -1; border-bottom: 0; }
  .inline-form, .inline-form.columns { grid-template-columns: 1fr; }
  .inline-form .wide { grid-column: auto; }
  .panel { padding: 18px 16px; }
}
