:root {
  --bg: #0d1117;
  --panel: rgba(22, 27, 34, 0.84);
  --panel-strong: #161b22;
  --border: rgba(255, 255, 255, 0.1);
  --muted: #8b949e;
  --text: #f0f6fc;
  --green: #00c853;
  --red: #ff1744;
  --orange: #ff9800;
  --blue: #2196f3;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  background:
    radial-gradient(circle at top left, rgba(33, 150, 243, 0.16), transparent 34rem),
    radial-gradient(circle at bottom right, rgba(0, 200, 83, 0.08), transparent 28rem),
    linear-gradient(145deg, #0d1117 0%, #10151d 50%, #0d1117 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.eyebrow,
.section-heading p {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.55rem, 4vw, 2.7rem);
  line-height: 1.08;
}

h2 {
  font-size: 1.05rem;
}

.status-pill {
  flex: 0 0 auto;
  border: 1px solid rgba(0, 200, 83, 0.45);
  border-radius: 999px;
  padding: 9px 14px;
  color: var(--green);
  background: rgba(0, 200, 83, 0.1);
  font-size: 0.86rem;
  font-weight: 800;
}

.tabs {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 6px;
  padding: 6px;
  margin-bottom: 22px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(22, 27, 34, 0.76);
  box-shadow: var(--shadow);
}

.tab-button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.tab-button.active {
  color: var(--text);
  background: linear-gradient(135deg, rgba(33, 150, 243, 0.24), rgba(0, 200, 83, 0.18));
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.dashboard-grid,
.journal-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.1fr);
  gap: 18px;
  align-items: start;
}

.safety-panel {
  grid-column: 2;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.section-heading {
  margin-bottom: 18px;
}

.journal-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.input-grid,
.journal-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span,
.direction-field legend {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  color: var(--text);
  background: rgba(13, 17, 23, 0.8);
  outline: none;
}

textarea {
  resize: vertical;
}

input[type="file"] {
  padding: 9px 12px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(33, 150, 243, 0.8);
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.15);
}

.direction-field {
  grid-column: span 2;
  border: 0;
  padding: 0;
  margin: 0;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.segmented input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.segmented label {
  min-height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--muted);
  background: rgba(13, 17, 23, 0.64);
  font-weight: 900;
  cursor: pointer;
}

#longDirection:checked + label {
  color: var(--green);
  border-color: rgba(0, 200, 83, 0.65);
  background: rgba(0, 200, 83, 0.12);
}

#shortDirection:checked + label {
  color: var(--red);
  border-color: rgba(255, 23, 68, 0.65);
  background: rgba(255, 23, 68, 0.12);
}

.actions,
.preset-buttons,
.form-actions,
.row-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.actions,
.preset-buttons {
  margin-top: 18px;
}

.primary-button,
.secondary-button,
.preset-buttons button,
.action-button {
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 16px;
  color: var(--text);
  font-weight: 900;
}

.primary-button {
  border-color: rgba(33, 150, 243, 0.55);
  background: linear-gradient(135deg, var(--blue), #1769aa);
}

.secondary-button,
.preset-buttons button,
.action-button {
  background: rgba(13, 17, 23, 0.82);
}

.compact-button {
  min-height: 38px;
  padding-inline: 12px;
  white-space: nowrap;
}

.preset-buttons button:hover,
.secondary-button:hover,
.action-button:hover {
  border-color: rgba(255, 152, 0, 0.7);
  color: var(--orange);
}

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

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

.mini-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  background: rgba(13, 17, 23, 0.58);
  overflow-wrap: anywhere;
}

.mini-card span,
.safety-status span,
.safety-risk span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.mini-card strong {
  font-size: 1.25rem;
}

.progress-track {
  height: 16px;
  margin-top: 18px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(13, 17, 23, 0.8);
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  transition: width 180ms ease, background-color 180ms ease;
}

.progress-fill.safe {
  background: var(--green);
}

.progress-fill.moderate {
  background: var(--orange);
}

.progress-fill.high {
  background: var(--red);
}

.progress-fill.extreme {
  background: var(--red);
  animation: flash-red 850ms infinite;
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 0.82rem;
}

.progress-labels strong {
  color: var(--text);
  text-align: center;
}

.safety-status,
.safety-risk {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  background: rgba(13, 17, 23, 0.58);
}

.safety-risk p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.risk-safe {
  color: var(--green);
}

.risk-moderate {
  color: var(--orange);
}

.risk-high,
.risk-extreme {
  color: var(--red);
}

@keyframes flash-red {
  0%,
  100% {
    filter: brightness(0.86);
  }

  50% {
    filter: brightness(1.45);
  }
}

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

.result-card,
.stat-card {
  min-height: 108px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 15px;
  background: rgba(13, 17, 23, 0.58);
  overflow-wrap: anywhere;
}

.stat-card {
  min-height: 96px;
}

.result-card span,
.summary-display span,
.stat-card span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.result-card strong {
  font-size: clamp(1.08rem, 2.5vw, 1.45rem);
}

.stat-card strong {
  font-size: clamp(1rem, 2vw, 1.25rem);
}

.accent-blue {
  border-top: 3px solid var(--blue);
}

.accent-red {
  border-top: 3px solid var(--red);
}

.accent-green {
  border-top: 3px solid var(--green);
}

.accent-orange {
  border-top: 3px solid var(--orange);
}

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

.summary-display div {
  display: grid;
  gap: 8px;
  border-left: 3px solid var(--blue);
  border-radius: 10px;
  padding: 12px;
  background: rgba(13, 17, 23, 0.58);
  overflow-wrap: anywhere;
}

.summary-display strong {
  font-size: 1rem;
}

.validation-message,
.leverage-warning,
.empty-state {
  margin: 16px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.validation-message.error,
.leverage-warning.error {
  color: var(--red);
}

.validation-message.success {
  color: var(--green);
}

.leverage-warning.warning {
  color: var(--orange);
}

.notes-field {
  grid-column: span 2;
}

.form-actions {
  grid-column: span 2;
}

.stats-panel {
  margin-top: 18px;
}

.journal-table-wrap {
  overflow-x: auto;
}

.journal-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

.journal-table th,
.journal-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.journal-table th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.journal-table td {
  color: var(--text);
}

.row-actions {
  min-width: 132px;
}

.action-button {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 0.8rem;
}

.delete-trade {
  border-color: rgba(255, 23, 68, 0.5);
  color: var(--red);
  background: rgba(255, 23, 68, 0.08);
}

.screenshot-link {
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
}

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

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

@media (max-width: 1100px) {
  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .dashboard-grid,
  .journal-layout {
    grid-template-columns: 1fr;
  }

  .safety-panel {
    grid-column: auto;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1240px);
    padding: 18px 0;
  }

  .app-header,
  .journal-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .tabs {
    width: 100%;
  }

  .panel {
    padding: 16px;
    border-radius: 14px;
  }

  .input-grid,
  .journal-form,
  .result-grid,
  .safety-readout,
  .summary-display,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .direction-field,
  .notes-field,
  .form-actions {
    grid-column: span 1;
  }

  .actions > *,
  .preset-buttons button,
  .form-actions > * {
    flex: 1 1 120px;
  }
}
