:root {
  --bg: #f3f6f8;
  --chrome: #eef2f5;
  --panel: #f9fbfc;
  --panel-2: #ffffff;
  --line: #dce4e9;
  --line-strong: #cbd6dd;
  --text: #606970;
  --text-strong: #27313a;
  --muted: #8d989f;
  --teal: #0da9ba;
  --teal-dark: #078d9f;
  --blue: #2f96f4;
  --red: #d84c45;
  --green: #109dad;
  --shadow: 0 1px 3px rgba(42, 54, 62, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
}

button,
select,
input {
  font: inherit;
}

button,
select,
.file-button {
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: linear-gradient(#ffffff, #f5f8fa);
  color: var(--text);
  padding: 0 12px;
  cursor: pointer;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.03);
}

button:hover,
select:hover,
.file-button:hover {
  border-color: #adc0ca;
  color: var(--text-strong);
}

.app-header {
  height: 50px;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 18px;
  background: #f8fafb;
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.brand {
  color: #0d1114;
  font-size: 28px;
  line-height: 1;
  letter-spacing: 1px;
  font-weight: 600;
}

.brand span {
  color: var(--teal);
}

.nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav button,
.header-actions button {
  border: 0;
  background: transparent;
  box-shadow: none;
  height: 30px;
  padding: 0 8px;
  font-weight: 600;
  color: #66717a;
}

.header-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

.version-tag {
  color: #8d989f;
  font-weight: 600;
}

.icon-btn {
  width: 34px;
  padding: 0;
  text-align: center;
  font-weight: 700;
}

.icon-btn.active {
  border-color: #55c9d6;
  color: var(--teal-dark);
  box-shadow: inset 0 0 0 1px #a6e7ee;
}

.terminal {
  padding: 10px 10px 0;
  min-width: 1040px;
}

.instrument-row {
  display: grid;
  grid-template-columns: 1fr 1.1fr 320px;
  gap: 10px;
  align-items: stretch;
  margin-bottom: 10px;
}

.instrument,
.search,
.date-band,
.toolbar,
.panel,
.stat-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: var(--shadow);
}

.instrument {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  min-height: 58px;
}

.instrument strong {
  color: var(--text-strong);
  font-size: 22px;
}

.instrument span {
  color: #8d959b;
  font-size: 18px;
}

.instrument small {
  color: #8c969d;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 6px;
  background: #f4f7f9;
}

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
}

.search span {
  font-size: 26px;
  color: #97a1a8;
}

.search select {
  width: 100%;
  border: 0;
  box-shadow: none;
  background: transparent;
  font-weight: 600;
  color: #7e8990;
}

.date-band {
  display: grid;
  grid-template-columns: 34px 34px 1fr 34px 34px;
  gap: 5px;
  align-items: center;
  padding: 10px;
}

.date-pill {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
  font-weight: 700;
}

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

.toolbar-spacer {
  flex: 1;
}

.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.date-input-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  color: #66717a;
  font-weight: 600;
}

.date-input-label input {
  height: 34px;
  width: 138px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  padding: 0 8px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(720px, 1fr) 330px;
  gap: 10px;
}

.charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.annual-panel {
  grid-column: 1 / -1;
}

.panel {
  min-height: 240px;
  padding: 10px;
  position: relative;
}

.annual-panel {
  min-height: 378px;
}

.panel-title {
  color: #8a959c;
  text-align: center;
  font-weight: 700;
  margin: 3px 0 2px;
}

svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  user-select: none;
}

.gridline {
  stroke: #dfe7ec;
  stroke-width: 1;
}

.axis-label {
  fill: #8b969d;
  font-size: 13px;
}

.season-muted {
  fill: none;
  stroke: #bdd6dc;
  stroke-width: 2.4;
  opacity: 0.76;
}

.season-active {
  fill: none;
  stroke: var(--blue);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.selection-fill {
  fill: rgba(47, 150, 244, 0.18);
  cursor: grab;
}

.selection-fill:active {
  cursor: grabbing;
}

.handle {
  stroke: #707b82;
  stroke-width: 2;
  cursor: ew-resize;
}

.handle-hit {
  stroke: transparent;
  stroke-width: 18;
  cursor: ew-resize;
}

.drag-label {
  fill: #4d5961;
  font-size: 13px;
  font-weight: 700;
}

.bar-pos {
  fill: var(--teal);
}

.bar-neg {
  fill: var(--red);
}

.stat-panel {
  padding: 12px;
  margin-bottom: 10px;
  text-align: center;
}

.stat-panel h3 {
  margin: 0 0 10px;
  font-size: 14px;
  color: #8a959c;
}

.donut-panel {
  min-height: 198px;
}

.legend {
  display: flex;
  justify-content: center;
  gap: 14px;
  font-size: 12px;
  margin-top: -4px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend i {
  width: 10px;
  height: 10px;
  display: inline-block;
  background: var(--teal);
}

.legend i.rest {
  background: #c9d1d6;
}

.hero-stats,
.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: stretch;
}

.hero-stats {
  margin-top: 12px;
}

.hero-stats div,
.metric-grid div {
  min-width: 0;
  padding: 8px;
}

.selected-box {
  border: 3px solid var(--teal);
}

.stat-panel strong {
  display: block;
  color: var(--teal);
  font-size: 18px;
  line-height: 1.15;
}

.stat-panel small {
  display: block;
  color: #8a959c;
  font-size: 11px;
  font-weight: 700;
}

.gain-loss {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.gain-loss div:last-child strong {
  color: var(--red);
}

.misc {
  margin-bottom: 0;
}

.status-bar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 10px;
  padding: 9px 12px;
  color: #829099;
  border-top: 1px solid var(--line);
  background: #f8fafb;
}

@media (max-width: 1180px) {
  .terminal {
    min-width: 0;
  }

  .instrument-row,
  .workspace {
    grid-template-columns: 1fr;
  }

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

  .stat-panel {
    margin-bottom: 0;
  }
}

@media (max-width: 760px) {
  .app-header,
  .toolbar {
    flex-wrap: wrap;
    height: auto;
  }

  .charts,
  .stats,
  .instrument-row {
    grid-template-columns: 1fr;
  }

  .date-band {
    grid-template-columns: 34px 34px minmax(120px, 1fr) 34px 34px;
  }
}
