* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f5f7fa;
  color: #333;
  min-height: 100vh;
  padding: 16px;
}

.container {
  max-width: 600px;
  margin: 0 auto;
}

h1 {
  font-size: 1.4rem;
  font-weight: 700;
  text-align: center;
  color: #1a56db;
  margin-bottom: 4px;
}

.subtitle {
  text-align: center;
  font-size: 0.82rem;
  color: #666;
  margin-bottom: 20px;
}

.card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  margin-bottom: 16px;
}

.form-group {
  margin-bottom: 16px;
}

label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 4px;
}

input[type="number"] {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.2s;
  -moz-appearance: textfield;
}

input[type="number"]:focus {
  outline: none;
  border-color: #1a56db;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  opacity: 1;
}

.hint {
  display: block;
  font-size: 0.75rem;
  color: #888;
  margin-top: 3px;
}

button {
  width: 100%;
  padding: 12px;
  background: #1a56db;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 4px;
}

button:hover {
  background: #1343a8;
}

button:active {
  background: #0e3080;
}

/* Result Card */
.result-card {
  background: #1a56db;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  color: #fff;
}

.result-main {
  text-align: center;
  margin-bottom: 16px;
}

.result-label {
  font-size: 0.85rem;
  opacity: 0.85;
  margin-bottom: 6px;
}

.result-value {
  font-size: 2.4rem;
  font-weight: 700;
  line-height: 1;
}

.result-value span {
  font-size: 2.4rem;
}

.result-sub {
  display: flex;
  gap: 12px;
}

.result-item {
  flex: 1;
  background: rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}

.r-label {
  display: block;
  font-size: 0.72rem;
  opacity: 0.85;
  margin-bottom: 4px;
}

.r-value {
  display: block;
  font-size: 1rem;
  font-weight: 600;
}

/* Chart */
.chart-section,
.table-section {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  margin-bottom: 16px;
}

h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 14px;
  color: #333;
}

.chart-container {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  height: 160px;
  border-bottom: 2px solid #e5e7eb;
  padding-bottom: 6px;
  margin-bottom: 8px;
  overflow-x: auto;
}

.chart-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 0 0 auto;
  width: 52px;
}

.bar-label {
  font-size: 0.68rem;
  color: #666;
  margin-bottom: 4px;
  white-space: nowrap;
}

.bar-wrap {
  width: 36px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 120px;
}

.bar {
  width: 100%;
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: height 0.3s;
}

.bar.loss { background: #ef4444; }
.bar.zero { background: #f59e0b; }
.bar.profit { background: #10b981; }

.bar-qty {
  font-size: 0.68rem;
  color: #555;
  margin-top: 4px;
}

.chart-legend {
  display: flex;
  gap: 16px;
  justify-content: center;
  font-size: 0.8rem;
}

.legend::before {
  content: '■';
  margin-right: 4px;
}

.legend.loss { color: #ef4444; }
.legend.zero { color: #f59e0b; }
.legend.profit { color: #10b981; }

/* Table */
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th {
  background: #f3f4f6;
  padding: 8px 10px;
  text-align: right;
  font-weight: 600;
  color: #555;
  border-bottom: 2px solid #e5e7eb;
}

th:first-child { text-align: center; }

td {
  padding: 8px 10px;
  text-align: right;
  border-bottom: 1px solid #f3f4f6;
}

td:first-child { text-align: center; font-weight: 600; }

tr.bep-row {
  background: #fef9c3;
  font-weight: 700;
}

tr.bep-row td { border-bottom: 2px solid #f59e0b; }

.loss-val { color: #ef4444; }
.profit-val { color: #10b981; }

@media (max-width: 375px) {
  h1 { font-size: 1.2rem; }
  .result-value { font-size: 2rem; }
  .result-sub { flex-direction: column; }
}
