/* Nordnet terminal -- light ledger aesthetic. White page, a quiet sidebar,
   dense tabular content as the main event. No cards, no shadows, no
   gradients: structure comes from hairline rules, alignment, and one
   accent color used sparingly. */

:root {
  --paper: #ffffff;
  --paper-raised: #f7f8f6;
  --ink: #202623;
  --ink-soft: #6b756f;
  --spruce: #1f6b4a;
  --spruce-ink: #ffffff;
  --fjord: #2f6a82;
  --gain: #22824f;
  --loss: #a8382a;
  --rule: #e4e6e0;
  --radius: 4px;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

/* Light by default, regardless of OS setting. Dark only when the user
   picks it with the sidebar toggle (sets data-theme on <html>). */
:root {
  color-scheme: light;
  --hover: rgb(0 0 0 / 4%);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #1a1f1d;
  --paper-raised: #212825;
  --ink: #e6ebe8;
  --ink-soft: #9aa5a0;
  --spruce: #5cbf92;
  --spruce-ink: #10160f;
  --fjord: #82b8cd;
  --gain: #55c08a;
  --loss: #e8806f;
  --rule: #313b36;
  --hover: rgb(255 255 255 / 6%);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
}

a {
  color: var(--fjord);
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--fjord);
  outline-offset: 2px;
}

.layout {
  display: grid;
  grid-template-columns: 15rem 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--paper-raised);
  color: var(--ink);
  border-right: 1px solid var(--rule);
  padding: 1.75rem 1.5rem;
  display: flex;
  flex-direction: column;
}

.sidebar .wordmark {
  color: var(--spruce);
  font-weight: 600;
  font-size: 1.1rem;
  margin: 0 0 2.25rem;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.sidebar nav a {
  color: var(--ink-soft);
  text-decoration: none;
  padding: 0.5rem 0.6rem;
  border-left: 3px solid transparent;
  border-radius: 0 var(--radius) var(--radius) 0;
  transition: background 0.15s, color 0.15s;
}

.sidebar nav a:hover {
  color: var(--ink);
  background: var(--hover);
}

.sidebar nav a.active {
  color: var(--spruce);
  border-left-color: var(--spruce);
  background: var(--hover);
  font-weight: 600;
}

.sidebar .equity {
  margin-top: auto;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
}

.sidebar .equity .label {
  color: var(--ink-soft);
  font-size: 0.8rem;
}

.sidebar .equity .value {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
}

.sidebar .controls {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-top: 1rem;
}

.sidebar .controls form {
  margin: 0;
}

.sidebar .controls button {
  width: 100%;
  text-align: left;
  background: none;
  color: var(--ink-soft);
  padding: 0.45rem 0.6rem;
  font-size: 0.9rem;
}

.sidebar .controls button:hover {
  background: var(--hover);
  color: var(--ink);
}

main {
  padding: clamp(1rem, 2.5vw, 3rem);
  min-width: 0;
}

h1 {
  font-size: 1.4rem;
  font-weight: 600;
  margin: 0 0 1.5rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--rule);
}

th {
  color: var(--ink-soft);
  font-weight: 500;
  font-size: 0.85rem;
}

td.num,
th.num {
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.table-total {
  display: flex;
  gap: 4rem;
  width: fit-content;
  margin: 0;
  padding: 0.55rem 0.75rem;
  font-weight: 600;
  border-top: 1.5px solid var(--ink);
}

.table-total span {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

/* Tabulator (tables.js), restyled onto the ledger tokens so it follows
   light/dark like everything else. */
.tabulator {
  font-family: var(--sans);
  font-size: 0.95rem;
  background: var(--paper);
  color: var(--ink);
  border: none;
  margin-bottom: 1.5rem;
}

.tabulator .tabulator-header {
  background: var(--paper);
  color: var(--ink-soft);
  border-bottom: 1px solid var(--rule);
  font-weight: 500;
  font-size: 0.85rem;
}

.tabulator .tabulator-header .tabulator-col {
  background: var(--paper);
  border-right: none;
}

.tabulator .tabulator-header .tabulator-col.tabulator-sortable:hover {
  background: var(--hover);
}

.tabulator .tabulator-header .tabulator-col .tabulator-header-filter input {
  font-family: var(--sans);
  font-size: 0.8rem;
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
}

.tabulator .tabulator-tableholder {
  background: var(--paper);
}

.tabulator .tabulator-row,
.tabulator .tabulator-row.tabulator-row-even {
  background: var(--paper);
  color: var(--ink);
  border-bottom: 1px solid var(--rule);
}

.tabulator .tabulator-row.tabulator-selectable:hover {
  background: var(--hover);
}

.tabulator .tabulator-row .tabulator-cell {
  padding: 0.5rem 0.75rem;
  border-right: none;
}

.tabulator .tabulator-cell.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.tabulator .tabulator-placeholder span {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.positive {
  color: var(--gain);
}

.negative {
  color: var(--loss);
}





.note {
  color: var(--ink-soft);
  font-size: 0.85rem;
}


form.search-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

form.search-form input[type="number"] {
  width: 7rem;
}

input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
  font-family: var(--sans);
  font-size: 0.95rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
}

textarea {
  font-family: var(--mono);
  font-size: 0.8rem;
  width: 100%;
  height: 5rem;
}

button,
a.button {
  font-family: var(--sans);
  font-size: 0.95rem;
  padding: 0.55rem 1.1rem;
  border: none;
  border-radius: var(--radius);
  background: var(--spruce);
  color: var(--spruce-ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

button:hover,
a.button:hover {
  background: color-mix(in srgb, var(--spruce) 85%, black);
}

h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 2rem 0 1rem;
}

.order-form {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  gap: 0.75rem 1rem;
  max-width: 52rem;
  margin-bottom: 2rem;
}

.order-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.order-form input,
.order-form select {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.order-form p {
  grid-column: 1 / -1;
  margin: 0;
}

pre {
  font-family: var(--mono);
  font-size: 0.8rem;
  background: var(--paper-raised);
  padding: 0.75rem;
  border-radius: var(--radius);
  overflow-x: auto;
}

.error {
  color: var(--loss);
  margin-bottom: 1rem;
}

.login-steps {
  max-width: 34rem;
}

.login-steps ol {
  padding-left: 1.2rem;
  color: var(--ink-soft);
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

/* Tablet and down: the sidebar becomes a top bar. */
@media (max-width: 64rem) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1.25rem;
    padding: 0.75rem clamp(1rem, 2.5vw, 3rem);
    border-right: none;
    border-bottom: 1px solid var(--rule);
    position: sticky;
    top: 0;
    z-index: 10;
  }

  .sidebar .wordmark {
    margin: 0;
  }

  .sidebar nav {
    flex-direction: row;
    gap: 0.25rem;
    overflow-x: auto;
  }

  .sidebar .equity {
    margin: 0 0 0 auto;
    padding: 0;
    border: none;
    text-align: right;
  }

  .sidebar .equity .label {
    display: none;
  }

  .sidebar .controls {
    flex-direction: row;
    margin: 0;
    padding: 0;
    border: none;
  }
}

/* Stacked instrument page: interleave both columns so trading comes first
   (chart, order ticket, order book, then the reference material). */
@media (max-width: 64rem) {
  .inst-main,
  .inst-side {
    display: contents;
  }

  .inst-grid > * {
    min-width: 0;
  }

  .chart-card { order: 1; }
  .ticket { order: 2; }
  .inst-side > section:nth-of-type(2) { order: 3; } /* order book */
  .inst-main > section:nth-of-type(2) { order: 4; } /* key figures */
  .inst-side > section:nth-of-type(3) { order: 5; } /* latest trades */
  .trade-via-card { order: 2; }
  .split { order: 6; }

  .chart-card,
  .ticket,
  .inst-grid > section {
    margin-bottom: 0;
  }
}

.sidebar .controls button {
  white-space: nowrap;
}

/* Phone. */
@media (max-width: 42rem) {
  .sidebar nav {
    order: 5;
    flex-basis: 100%;
  }

  .sidebar .equity .value {
    font-size: 0.95rem;
  }

  .inst-head {
    align-items: flex-start;
  }

  .headline {
    text-align: left;
  }

  .periods {
    width: 100%;
  }

  .periods button {
    flex: 1;
    min-width: 0;
    padding: 0.3rem 0.2rem;
  }

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

/* Big screens / TVs: scale the whole rem-based layout up. */
@media (min-width: 2200px) {
  html {
    font-size: 112.5%;
  }
}

@media (min-width: 3000px) {
  html {
    font-size: 137.5%;
  }
}

a.button.small {
  font-size: 0.8rem;
  padding: 0.2rem 0.7rem;
}

form.inline {
  display: inline-flex;
  gap: 0.3rem;
  align-items: center;
  margin-right: 0.4rem;
}

form.inline input[type="number"] {
  width: 6rem;
  padding: 0.2rem 0.4rem;
  font-family: var(--mono);
  font-size: 0.8rem;
}

button.small {
  font-size: 0.8rem;
  padding: 0.2rem 0.7rem;
}

button.danger {
  background: var(--loss);
}

.muted {
  color: var(--ink-soft);
  font-weight: 400;
}

/* ---- Instrument page: full-width header, then main + side columns ---- */

.inst-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 2rem;
  flex-wrap: wrap;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 1.5rem;
}

.inst-head h1 {
  margin: 0 0 0.35rem;
  font-size: 1.6rem;
}

.inst-head .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.inst-head .status::before {
  content: "";
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  margin-right: 0.35rem;
  background: var(--ink-soft);
}

.inst-head .status.open::before {
  background: var(--gain);
}

.headline {
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.headline .last {
  font-size: 2.1rem;
  font-weight: 600;
  line-height: 1.1;
}

.headline .last small {
  font-size: 0.9rem;
  color: var(--ink-soft);
  font-weight: 400;
}

.inst-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(21rem, 27rem);
  gap: clamp(1.5rem, 2.5vw, 3rem);
  align-items: start;
}

.inst-main > section,
.inst-side > section {
  margin-bottom: 2rem;
}

.inst-main h2,
.inst-side h2 {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}

.split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
  gap: 2rem;
}

@media (max-width: 64rem) {
  .inst-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Chart */
.chart-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-bottom: 0.5rem;
}

.readout {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
  min-height: 1.4rem;
}

.periods {
  display: flex;
  gap: 0.25rem;
}

.periods button {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 4.2rem;
  padding: 0.3rem 0.6rem;
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 600;
}

.periods button:hover {
  background: var(--hover);
}

.periods button[aria-selected="true"] {
  color: var(--ink);
  border-color: var(--rule);
  background: var(--paper-raised);
}

.periods .ret {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 400;
  min-height: 1em;
}

.chart-canvas {
  height: clamp(15rem, 42vh, 40rem);
  transition: opacity 0.15s;
}

.chart-card.loading .chart-canvas {
  opacity: 0.45;
}

.chart-empty {
  margin: -12rem 0 10rem;
  text-align: center;
}

/* Key figures: label over value, auto-flowing columns */
.keyfigs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  gap: 0;
  margin: 0;
  border-top: 1px solid var(--rule);
}

.keyfigs > div {
  padding: 0.6rem 0.75rem 0.6rem 0;
  border-bottom: 1px solid var(--rule);
}

.keyfigs dt {
  font-size: 0.75rem;
  color: var(--ink-soft);
}

.keyfigs dd {
  margin: 0.1rem 0 0;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
}

/* Order ticket in the side column: two compact columns */
.ticket {
  padding: 1rem;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}

.ticket .order-form {
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem 0.75rem;
  max-width: none;
  margin: 0;
}

.ticket .order-form .wide,
.ticket .side-toggle {
  grid-column: 1 / -1;
}

.ticket .order-form input,
.ticket .order-form select {
  width: 100%;
}

.ticket button[type="submit"] {
  width: 100%;
}

.side-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
}

.side-toggle label {
  flex-direction: row !important;
  justify-content: center;
  padding: 0.45rem;
  font-size: 0.9rem !important;
  font-weight: 600;
  cursor: pointer;
  color: var(--ink-soft) !important;
  background: var(--paper);
}

.side-toggle label {
  position: relative;
}

/* Visually hidden but still focusable/keyboard-operable radios. */
.side-toggle input,
.ticket .order-form .side-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.side-toggle label:has(input:checked).buy {
  background: var(--gain);
  color: var(--spruce-ink) !important;
}

.side-toggle label:has(input:checked).sell {
  background: var(--loss);
  color: #fff !important;
}

.side-toggle label:has(input:focus-visible) {
  outline: 2px solid var(--fjord);
  outline-offset: -2px;
}

/* Grid children default to min-width:auto, so a wide Tabulator grid would
   push past its column and paint over the neighbour. Clip and scroll instead. */
.split > section,
.inst-main,
.inst-side {
  min-width: 0;
}

.tabulator {
  max-width: 100%;
  overflow-x: auto;
}

/* Non-tradable (index) view: no order column, main content takes the width. */
.inst-grid.no-side {
  grid-template-columns: minmax(0, 1fr);
}

.inst-head .badge {
  padding: 0 0.5rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-size: 0.75rem;
  line-height: 1.5rem;
}

.trade-via {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

a.button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--rule);
}

a.button.ghost:hover {
  background: var(--hover);
}

/* Corporate action detail */
.section-label {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}

.ca-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(18rem, 1fr);
  gap: clamp(1.5rem, 2.5vw, 3rem);
  margin: 2rem 0;
  align-items: start;
}

.ca-grid > section {
  min-width: 0;
}

.terms-body {
  max-width: 46rem;
  line-height: 1.65;
}

.terms-body ul {
  padding-left: 1.2rem;
}

.terms-body li {
  margin-bottom: 0.35rem;
}

.terms details {
  margin-top: 1rem;
  border-top: 1px solid var(--rule);
  padding-top: 0.75rem;
}

.terms summary {
  cursor: pointer;
  color: var(--fjord);
  font-size: 0.9rem;
}

@media (max-width: 64rem) {
  .ca-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.auth-form {
  display: grid;
  gap: 1rem;
  max-width: 22rem;
}

.auth-form label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.auth-form input[type="password"],
.auth-form input[type="text"] {
  font-family: var(--mono);
  font-size: 1rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
}

/* Live order cost in the ticket */
.ticket .cost {
  margin: 0;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.ticket .cost div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.85rem;
}

.ticket .cost dt {
  color: var(--ink-soft);
  font-family: var(--sans);
}

.ticket .cost dd {
  margin: 0;
}

.ticket .cost .total {
  margin-top: 0.3rem;
  padding-top: 0.3rem;
  border-top: 1px solid var(--rule);
  font-weight: 600;
}

.ticket .order-form .note {
  margin: 0;
  font-size: 0.75rem;
}
