:root {
  --bg: #070b0d;
  --panel: #12171d;
  --panel-deep: #0c1114;
  --line: #283239;
  --line-soft: #20292f;
  --text: #f4f7f5;
  --muted: #8e9ba3;
  --muted-dim: #59666d;
  --green: #82f451;
  --red: #ff6269;
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(900px 760px at -8% 8%, rgba(31, 101, 64, .24), transparent 63%),
    radial-gradient(700px 620px at 104% 100%, rgba(23, 68, 56, .07), transparent 68%),
    linear-gradient(120deg, #08110e 0%, var(--bg) 45%, #080c0e 100%);
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(34, 98, 65, .08), transparent 28%);
}

button, input, select { font: inherit; }
button { cursor: pointer; }
.ambient { display: none; }
.hidden { display: none !important; }
.positive { color: var(--green) !important; }
.negative { color: var(--red) !important; }
.neutral { color: var(--text) !important; }

.shell {
  width: min(1140px, calc(100% - 40px));
  margin: 0 auto;
  padding: 42px 0 58px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.eyebrow,
.section-kicker {
  color: var(--green);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .2em;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.eyebrow span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 12px rgba(130, 244, 81, .65);
}

h1 {
  margin: 0;
  font-size: clamp(31px, 3vw, 38px);
  line-height: 1;
  letter-spacing: -.045em;
}

.subtitle { margin: 10px 0 0; color: var(--muted); font-size: 12px; }
h2 { margin: 4px 0 0; font-size: 18px; line-height: 1.2; letter-spacing: -.025em; }

h2 em {
  display: inline-grid;
  min-width: 22px;
  height: 22px;
  margin-left: 6px;
  padding: 0 6px;
  place-items: center;
  border-radius: 99px;
  background: #20282d;
  color: var(--muted);
  font-size: 10px;
  font-style: normal;
  vertical-align: 2px;
}

.button {
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: #171d22;
  font-size: 12px;
  font-weight: 750;
  transition: border-color .15s ease, background .15s ease;
}

.button:hover { border-color: #3b484f; background: #1b2328; }
.button-primary { color: #071006; border-color: var(--green); background: var(--green); }
.button-primary:hover { border-color: #98ff70; background: #98ff70; }
.button-ghost { background: transparent; }
.button-danger { color: var(--red); border-color: transparent; background: transparent; }
.button-danger:hover { border-color: rgba(255, 98, 105, .28); background: rgba(255, 98, 105, .05); }
.button-danger-solid { color: #170304; border-color: var(--red); background: var(--red); }
.button-plus { margin-right: 5px; font-size: 17px; }
.text-button { padding: 0; border: 0; color: var(--green); background: none; font-size: 11px; }
.text-button:hover { text-decoration: underline; }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 11px;
  margin-bottom: 13px;
}

.metric,
.entry-card,
.ledger-card {
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(18, 23, 29, .94);
}

.metric {
  min-height: 102px;
  padding: 17px 19px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.metric-featured { border-color: #304034; }
.metric-icon { display: none; }
.metric p { margin: 0; color: #95a8b8; font-size: 11px; }
.metric strong {
  display: block;
  margin: 6px 0 3px;
  font-size: clamp(23px, 2.2vw, 29px);
  line-height: 1;
  letter-spacing: -.04em;
  white-space: nowrap;
}
.metric strong small { color: var(--muted); font-size: .43em; letter-spacing: 0; }
.metric span { color: var(--muted-dim); font-size: 9px; }
.metric-count strong { font-size: 31px; }

.entry-card {
  width: 100%;
  margin-bottom: 13px;
  padding: 18px 19px 19px;
}

.section-heading,
.ledger-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.section-heading { margin-bottom: 14px; }
.entry-heading-side,
.entry-meta,
.ledger-actions { display: flex; align-items: center; gap: 8px; }
.entry-heading-side { gap: 14px; }

.auto-date,
.auto-fee {
  min-height: 42px;
  padding: 7px 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border: 1px solid #303b41;
  border-radius: 8px;
  background: var(--panel-deep);
}

.auto-date { min-width: 176px; }
.auto-fee { min-width: 92px; border-color: rgba(130, 244, 81, .28); }
.auto-date > span,
.auto-fee > span { color: #68757b; font-size: 8px; font-weight: 850; letter-spacing: .15em; }
.auto-date strong,
.auto-fee strong { margin-top: 2px; font-size: 12px; }
.auto-fee strong { color: var(--green); font-size: 13px; }
.auto-date small, .auto-fee small { display: none; }

.form-grid { display: grid; gap: 9px; }
.form-grid-main { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid-rates {
  grid-template-columns: minmax(140px, 1fr) 25px minmax(140px, 1fr) minmax(140px, .8fr) minmax(190px, 1.15fr);
  align-items: start;
}

.field { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.field > span { color: #929e9a; font-size: 10px; font-weight: 700; }

.field input,
.filters input,
.filters select {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  outline: none;
  border: 1px solid #303b41;
  border-radius: 9px;
  color: var(--text);
  background: var(--panel-deep);
  transition: border-color .15s ease, box-shadow .15s ease;
}

.field input:focus,
.filters input:focus,
.filters select:focus {
  border-color: rgba(130, 244, 81, .6);
  box-shadow: 0 0 0 3px rgba(130, 244, 81, .07);
}

.field input::placeholder,
.filters input::placeholder { color: #4f5b60; }
.field-hint { color: var(--muted-dim); font-size: 9px; line-height: 1.35; }
.input-wrap { position: relative; }
.input-wrap input { padding-right: 36px; }
.input-wrap b {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  color: #6a767b;
  font-size: 11px;
}

.rate-connector {
  height: 42px;
  margin-top: 22px;
  display: grid;
  place-items: center;
  color: var(--muted-dim);
}
.rate-connector span {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  font-size: 11px;
}
.divider { height: 1px; margin: 15px 0; background: var(--line-soft); }

.live-result {
  min-height: 62px;
  margin-top: 13px;
  padding: 9px 11px 9px 14px;
  display: grid;
  grid-template-columns: 1.42fr .7fr .74fr .76fr auto;
  align-items: center;
  gap: 14px;
  border: 1px solid rgba(130, 244, 81, .22);
  border-radius: 10px;
  background: #0d1712;
}

.formula-block > span,
.result-block > span {
  display: block;
  margin-bottom: 5px;
  color: #6d7a73;
  font-size: 8px;
  font-weight: 850;
  letter-spacing: .14em;
}
.formula-block p { margin: 0; color: #aeb8b2; font-size: 11px; }
.formula-block p b { color: var(--text); }
.formula-block p strong { margin-left: 4px; font-size: 14px; }
.result-block strong { font-size: 15px; letter-spacing: -.02em; }
.result-block small { color: var(--muted); font-size: 9px; }
.submit-button { min-height: 40px; height: 40px; padding-inline: 16px; white-space: nowrap; }
.submit-button span { margin-left: 12px; }

.ledger-card { overflow: hidden; }
.ledger-head { padding: 19px 20px 14px; }
.filters {
  padding: 0 20px 15px;
  display: grid;
  grid-template-columns: 1fr 164px 164px;
  gap: 8px;
}
.filters select { padding: 0 33px 0 11px; color: #bec6c9; }
.search { position: relative; }
.search input { padding-left: 38px; }
.search svg {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 12px;
  width: 15px;
  height: 15px;
  transform: translateY(-50%);
  fill: none;
  stroke: #667279;
  stroke-width: 1.8;
}

.table-wrap {
  position: relative;
  overflow-x: auto;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}
table { width: 100%; min-width: 1080px; border-collapse: collapse; }
thead { background: #10151a; }
th {
  padding: 11px;
  color: #7890a4;
  font-size: 8px;
  font-weight: 850;
  letter-spacing: .13em;
  text-align: right;
  text-transform: uppercase;
}
th:first-child { width: 24%; padding-left: 20px; text-align: left; }
th:last-child { width: 70px; }
td {
  padding: 13px 11px;
  border-top: 1px solid var(--line-soft);
  text-align: right;
  white-space: nowrap;
  font-size: 11px;
}
td:first-child { padding-left: 20px; text-align: left; }
tbody tr { transition: background .15s ease; }
tbody tr:hover { background: rgba(255, 255, 255, .018); }

.trade-primary { display: flex; align-items: center; gap: 10px; }
.trade-dot {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border: 2px solid var(--green);
  border-radius: 50%;
  box-shadow: 0 0 9px rgba(130, 244, 81, .3);
}
.trade-dot.loss { border-color: var(--red); box-shadow: 0 0 9px rgba(255, 98, 105, .25); }
.trade-name {
  display: block;
  max-width: 240px;
  overflow: hidden;
  color: var(--text);
  font-weight: 700;
  text-overflow: ellipsis;
}
.trade-meta { display: block; margin-top: 3px; color: var(--muted-dim); font-size: 9px; }
.cell-main { color: #e3e8e5; font-weight: 650; }
.cell-sub { display: block; margin-top: 3px; color: var(--muted-dim); font-size: 8px; }
.yield-pill {
  display: inline-block;
  margin-left: 5px;
  padding: 2px 5px;
  border: 1px solid rgba(130, 244, 81, .16);
  border-radius: 99px;
  color: #aac99e;
  background: rgba(130, 244, 81, .06);
  font-size: 8px;
}
.row-actions { display: flex; justify-content: flex-end; gap: 3px; }
.icon-button {
  width: 28px;
  height: 28px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 7px;
  color: #747f84;
  background: transparent;
  font-size: 11px;
}
.icon-button:hover { border-color: var(--line); color: var(--text); background: #192025; }
.icon-button.delete:hover { border-color: rgba(255, 98, 105, .22); color: var(--red); }

.empty-state { display: none; min-height: 218px; padding: 40px 20px; text-align: center; }
.empty-state.visible { display: block; }
.empty-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
  border: 1px solid #303b41;
  border-radius: 11px;
  color: var(--green);
  background: #151c20;
  font-size: 18px;
}
.empty-state h3 { margin: 0 0 6px; font-size: 15px; }
.empty-state p { margin: 0 0 14px; color: var(--muted); font-size: 11px; }
.table-footer {
  padding: 11px 20px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  color: var(--muted-dim);
  font-size: 9px;
}
.table-footer b { color: #929fa3; }

.toast {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: 24px;
  min-width: 210px;
  padding: 11px 16px;
  border: 1px solid #354148;
  border-radius: 9px;
  color: var(--text);
  background: #171e23;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .4);
  opacity: 0;
  pointer-events: none;
  text-align: center;
  transform: translate(-50%, 25px);
  transition: opacity .2s ease, transform .2s ease;
  font-size: 11px;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

dialog {
  width: min(410px, calc(100% - 30px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 15px;
  color: var(--text);
  background: var(--panel);
  box-shadow: 0 28px 80px rgba(0, 0, 0, .7);
}
dialog::backdrop { background: rgba(0, 0, 0, .72); backdrop-filter: blur(4px); }
dialog form { padding: 25px; text-align: center; }
.dialog-icon {
  width: 42px;
  height: 42px;
  margin: 0 auto 13px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 98, 105, .22);
  border-radius: 50%;
  color: var(--red);
  background: rgba(255, 98, 105, .09);
  font-weight: 800;
}
dialog h3 { margin: 0 0 7px; }
dialog p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.dialog-actions { margin-top: 21px; display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }

@media (max-width: 1180px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .form-grid-rates { grid-template-columns: 1fr 24px 1fr 1fr; }
  .field-note { grid-column: 1 / -1; }
  .live-result { grid-template-columns: 1.25fr 1fr 1fr 1fr; }
  .submit-button { grid-column: 1 / -1; }
}

@media (max-width: 820px) {
  .shell { width: min(100% - 24px, 720px); padding-top: 26px; }
  .subtitle { display: none; }
  .metrics { grid-template-columns: 1fr 1fr; gap: 8px; }
  .metric { min-height: 96px; padding: 15px; }
  .section-heading { align-items: flex-start; }
  .entry-heading-side { flex-direction: column; align-items: flex-end; }
  .form-grid-rates { grid-template-columns: 1fr 25px 1fr; }
  .field-note { grid-column: 1 / -1; }
  .live-result { grid-template-columns: 1fr 1fr; }
  .formula-block { grid-column: 1 / -1; }
  .filters { grid-template-columns: 1fr 1fr; }
  .search { grid-column: 1 / -1; }
  .table-footer { flex-direction: column; gap: 4px; }
}

@media (max-width: 560px) {
  .shell { width: min(100% - 18px, 520px); padding: 18px 0 32px; }
  .topbar { margin-bottom: 18px; }
  h1 { font-size: 31px; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric { min-height: 91px; padding: 13px; }
  .metric strong { font-size: 20px; }
  .entry-card { padding: 16px 13px; }
  .section-heading { align-items: stretch; flex-direction: column; }
  .entry-heading-side, .entry-meta { width: 100%; }
  .entry-heading-side { align-items: stretch; }
  .entry-meta > div { flex: 1; min-width: 0; }
  .form-grid-main, .form-grid-rates, .live-result { grid-template-columns: 1fr; }
  .field-note, .formula-block, .submit-button { grid-column: auto; }
  .rate-connector { display: none; }
  .ledger-head { padding: 17px 14px 13px; align-items: flex-start; flex-direction: column; }
  .ledger-actions { width: 100%; }
  .ledger-actions .button { flex: 1; }
  .filters { padding: 0 14px 14px; grid-template-columns: 1fr; }
  .search { grid-column: auto; }
}
