:root {
  --desktop: #efefef;
  --paper: #f6f2ea;
  --window: #fbf7ef;
  --control-side: 340px;
  --line: #1b1b1b;
  --line-soft: #6f6a61;
  --text: #161616;
  --muted: #55514a;
  --accent: #000000;
  --positive: #1e6f3f;
  --negative: #8a2c2c;
  --warning: #8a5a00;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: 'Noto Sans KR', sans-serif;
  background:
    radial-gradient(circle at 1px 1px, rgba(0, 0, 0, 0.08) 1px, transparent 0),
    var(--desktop);
  background-size: 10px 10px;
}

button,
input,
select {
  font: inherit;
}

.bg-orb {
  display: none;
}

.app-shell {
  width: min(1280px, calc(100% - 28px));
  margin: 14px auto 28px;
  display: grid;
  gap: 14px;
}

.dashboard-grid,
.grid.two {
  display: grid;
  gap: 14px;
}

.dashboard-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  align-items: start;
}

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

.hero-card,
.panel,
.nav-link,
button,
input,
select,
.focus-card,
.compact-item,
.position-card,
.metric,
.order-pill {
  border: 2px solid var(--line);
  border-radius: 14px;
}

.hero-card,
.panel {
  position: relative;
  background: var(--window);
  padding: 16px;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.18);
}

.hero-card::before,
.panel::before {
  content: '';
  display: block;
  height: 30px;
  margin: -16px -16px 14px;
  border-bottom: 2px solid var(--line);
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
  background:
    radial-gradient(circle at 16px 50%, #000 0 2px, transparent 2.5px),
    radial-gradient(circle at calc(100% - 16px) 50%, #000 0 2px, transparent 2.5px),
    repeating-linear-gradient(90deg, transparent 0 6px, rgba(0, 0, 0, 0.08) 6px 8px),
    var(--paper);
}

.hero-card {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.hero-card > div {
  width: 100%;
  text-align: center;
}

.hero-card .eyebrow,
.hero-card h1,
.hero-card .hero-copy {
  margin-left: auto;
  margin-right: auto;
}

.hero-card .hero-copy {
  max-width: 860px;
}

.top-nav {
  display: flex;
  gap: 8px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
  background: var(--paper);
  color: var(--text);
  text-decoration: none;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.14);
}

.nav-link.active {
  background: #ffffff;
}

.eyebrow,
.panel-label,
h1,
h2,
h3,
.nav-link,
button {
  font-family: 'VT323', monospace;
}

.eyebrow,
.panel-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 18px;
  letter-spacing: 0.02em;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 400;
}

h1 {
  max-width: 760px;
  font-size: clamp(32px, 4vw, 50px);
  line-height: 1.08;
}

h2 {
  font-size: 32px;
  line-height: 1.08;
}

h3 {
  font-size: 26px;
}

.hero-copy,
.section-note,
.compact-item span,
.stats-row span,
.runtime-form span,
.metric span,
.log-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.hero-actions,
.stats-row,
.panel-head,
.runtime-form,
.positions,
.position-card,
.metrics,
.log-list,
.log-item,
.control-top,
.control-bottom,
.control-note-wrap,
.compact-list {
  display: grid;
}

.hero-actions {
  min-width: 200px;
  gap: 8px;
}

button {
  min-height: 38px;
  padding: 8px 14px;
  cursor: pointer;
  background: var(--paper);
  color: var(--text);
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.14);
}

button:active,
.nav-link:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}

.primary,
.ghost {
  background: var(--paper);
}

.wide {
  width: 100%;
}

.panel-head {
  grid-template-columns: 1fr;
  align-items: center;
  margin-bottom: 12px;
}

.tile {
  min-height: 100%;
}

.tile-control,
.tile-errors {
  grid-column: span 12;
}

.tile-positions,
.tile-logs {
  grid-column: span 6;
}

.stats-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.stats-row > div,
.metric {
  background: #fffdf8;
  padding: 10px;
  min-height: 72px;
  border: 2px solid var(--line);
  border-radius: 12px;
}

.stats-row strong,
.metric strong,
.focus-card strong {
  display: block;
  margin-top: 6px;
  font-family: 'VT323', monospace;
  font-size: 28px;
  color: var(--text);
}

.runtime-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.control-top,
.control-bottom,
.control-note-wrap,
.compact-list {
  gap: 10px;
}

.control-top {
  grid-template-columns: minmax(0, var(--control-side)) 1fr;
  align-items: start;
  margin-bottom: 12px;
}

.inline-stats {
  margin-top: 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.control-bottom {
  grid-template-columns: minmax(0, var(--control-side)) 1fr;
  align-items: start;
}

.control-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.focus-card {
  background: transparent;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

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

.focus-value-box {
  margin-top: 8px;
  min-height: 34px;
  padding: 6px 10px;
  background: #ffffff;
  border: 2px solid var(--line);
  border-radius: 12px;
  box-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.08);
}

.focus-value-box strong {
  margin-top: 0;
}

.runtime-form label {
  display: grid;
  gap: 6px;
}

.runtime-form input,
.runtime-form select {
  width: 100%;
  min-height: 34px;
  padding: 6px 10px;
  background: #ffffff;
  color: var(--text);
  box-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.08);
}

.toggle-row {
  align-content: end;
}

.toggle-row input {
  width: 18px;
  height: 18px;
}

.positions,
.log-list,
.compact-list {
  gap: 10px;
}

.compact-item,
.position-card,
.log-item {
  background: #fffdf8;
  padding: 10px;
}

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

.auto-buy-stats,
.compact-stats {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.position-card {
  gap: 12px;
}

.position-top,
.ledger-entry-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.badge,
.order-pill {
  padding: 6px 10px;
  background: var(--paper);
  font-size: 12px;
  color: var(--text);
}

.badge.live {
  color: var(--positive);
}

.badge.simulation {
  color: var(--warning);
}

.metrics {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.positive {
  color: var(--positive) !important;
}

.negative {
  color: var(--negative) !important;
}

.orders {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.log-item strong,
.monthly-card strong {
  font-size: 24px;
}

.tile-errors .log-list,
.tile-logs .log-list {
  max-height: 420px;
  overflow: auto;
  padding-right: 4px;
}

.small {
  width: auto;
  padding: 6px 10px;
  font-size: 12px;
}

.ledger-entry-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.auto-pill {
  color: var(--accent);
}

.calendar-notes {
  display: grid;
  gap: 4px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.calendar-table-wrap {
  overflow: auto;
  max-height: 360px;
}

.calendar-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1240px;
  background: #fffdf8;
}

.calendar-table th,
.calendar-table td {
  padding: 10px 12px;
  border: 2px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

.calendar-table th:nth-child(-n+3),
.calendar-table td:nth-child(-n+3) {
  text-align: left;
}

.calendar-table th {
  background: var(--paper);
  font-family: 'VT323', monospace;
  font-size: 20px;
  position: sticky;
  top: 0;
  z-index: 1;
}

@media (max-width: 900px) {
  .dashboard-grid,
  .grid.two,
  .runtime-form,
  .metrics,
  .auto-buy-stats,
  .monthly-grid,
  .control-top,
  .control-bottom,
  .inline-stats,
  .control-form {
    grid-template-columns: 1fr;
  }

  .dashboard-grid > .tile {
    grid-column: span 1;
  }

  .hero-card,
  .top-nav,
  .position-top,
  .ledger-entry-head {
    flex-direction: column;
    align-items: flex-start;
  }
}
