:root {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #111827;
  background-color: #0f172a;
}

body.light-theme {
  background-color: #f3f4f6;
  color: #111827;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
}

.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
  color: #e5e7eb;
}

body.light-theme .app-container {
  color: #111827;
}

header {
  margin-bottom: 1.5rem;
}

.header-main {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

header h1 {
  margin: 0;
  font-size: 2rem;
}

header p {
  margin: 0.25rem 0 0;
  color: #9ca3af;
}

body.light-theme header p {
  color: #4b5563;
}

.theme-toggle {
  border-radius: 999px;
  border: 1px solid #374151;
  background-color: #020617;
  color: #e5e7eb;
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  cursor: pointer;
}

body.light-theme .theme-toggle {
  background-color: #e5e7eb;
  color: #111827;
  border-color: #d1d5db;
}

main {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card {
  background: #020617;
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  border: 1px solid #1f2937;
}

body.light-theme .card {
  background: #ffffff;
  border-color: #e5e7eb;
}

.card h2 {
  margin-top: 0;
  margin-bottom: 0.75rem;
  font-size: 1.1rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem 1rem;
}

.slim-grid {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

label {
  display: flex;
  flex-direction: column;
  font-size: 0.9rem;
  gap: 0.25rem;
}

input,
select {
  border-radius: 0.5rem;
  border: 1px solid #374151;
  padding: 0.45rem 0.6rem;
  font-size: 0.95rem;
  background-color: #020617;
  color: #e5e7eb;
}

body.light-theme input,
body.light-theme select {
  background-color: #ffffff;
  color: #111827;
  border-color: #d1d5db;
}

input[type="range"] {
  padding: 0;
}

input:focus,
select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 1px #3b82f6;
}

.inline-input {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.inline-input .prefix {
  padding: 0.35rem 0.6rem;
  border-radius: 0.5rem;
  border: 1px solid #374151;
  background-color: #020617;
  font-size: 0.9rem;
  color: #9ca3af;
}

body.light-theme .inline-input .prefix {
  background-color: #f9fafb;
  border-color: #d1d5db;
  color: #6b7280;
}

.inline-input input {
  flex: 1;
}

.quick-buttons {
  margin-top: 0.35rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.quick-buttons.small-gap {
  margin-top: 0.25rem;
}

.quick-buttons button {
  border-radius: 999px;
  border: 1px solid #374151;
  background-color: #020617;
  color: #e5e7eb;
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
  cursor: pointer;
}

body.light-theme .quick-buttons button {
  background-color: #f9fafb;
  color: #111827;
  border-color: #d1d5db;
}

.quick-buttons button:hover {
  border-color: #3b82f6;
}

.preset-select {
  margin-top: 0.35rem;
}

.hint {
  margin-top: 0.25rem;
  color: #9ca3af;
  font-size: 0.75rem;
}

body.light-theme .hint {
  color: #6b7280;
}

.hint.small-top {
  margin-top: 0.15rem;
}

.details-block {
  margin-top: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: 0.5rem;
  background-color: rgba(15, 23, 42, 0.6);
  border: 1px solid #1f2937;
  font-size: 0.85rem;
}

body.light-theme .details-block {
  background-color: #f9fafb;
  border-color: #e5e7eb;
}

.details-block summary {
  cursor: pointer;
  font-weight: 500;
}

.details-block p.details-note {
  margin: 0.35rem 0 0.5rem;
}

.mix-grid {
  margin-top: 0.5rem;
  display: grid;
  gap: 0.35rem;
}

.mix-row {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 0.5rem;
  align-items: center;
}

.mix-header {
  font-size: 0.8rem;
  color: #9ca3af;
}

.details-note {
  color: #d1d5db;
}

body.light-theme .details-note {
  color: #6b7280;
}

.cagr-info {
  margin-top: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: 0.5rem;
  background-color: rgba(15, 23, 42, 0.85);
  border: 1px solid #1f2937;
  font-size: 0.85rem;
}

body.light-theme .cagr-info {
  background-color: #f9fafb;
  border-color: #e5e7eb;
}

.cagr-info summary {
  cursor: pointer;
  font-weight: 500;
}

.cagr-info p {
  margin: 0.35rem 0;
  color: #d1d5db;
}

body.light-theme .cagr-info p {
  color: #4b5563;
}

.cagr-info .formula {
  font-family: "SF Mono", ui-monospace, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.8rem;
}

.cagr-info .note {
  color: #9ca3af;
}

body.light-theme .cagr-info .note {
  color: #6b7280;
}

.actions {
  margin-top: 0.75rem;
  display: flex;
  justify-content: flex-end;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  padding-top: 0.5rem;
  background: linear-gradient(to top, rgba(2, 6, 23, 0.95), rgba(2, 6, 23, 0));
}

body.light-theme .sticky-actions {
  background: linear-gradient(to top, rgba(249, 250, 251, 0.95), rgba(249, 250, 251, 0));
}

button[type="submit"] {
  border-radius: 999px;
  border: 1px solid #1f2937;
  padding: 0.5rem 1.2rem;
  font-size: 0.9rem;
  cursor: pointer;
  background-color: #1f2937;
  color: #f9fafb;
  font-weight: 500;
}

button[type="submit"]:hover {
  background-color: #111827;
}

.secondary-btn {
  border-radius: 999px;
  border: 1px solid #374151;
  padding: 0.5rem 1.2rem;
  font-size: 0.9rem;
  cursor: pointer;
  background: transparent;
  color: #e5e7eb;
}

body.light-theme .secondary-btn {
  border-color: #d1d5db;
  color: #111827;
}

button[type="submit"]:disabled {
  opacity: 0.6;
  cursor: default;
}

.error-box {
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid #b91c1c;
  background-color: rgba(248, 113, 113, 0.08);
  color: #fecaca;
  font-size: 0.85rem;
}

.layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.6rem;
}

.summary-actions {
  margin-top: 0.6rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.summary-card {
  border-radius: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: radial-gradient(circle at top left, rgba(34, 197, 94, 0.14), rgba(15, 23, 42, 0.95));
  border: 1px solid #16a34a;
}

body.light-theme .summary-card {
  background: #ecfdf5;
  border-color: #bbf7d0;
}

.summary-card h3 {
  margin: 0;
  font-size: 0.95rem;
}

.summary-card p {
  margin: 0.1rem 0;
  font-size: 0.85rem;
}

.summary-card .value {
  font-size: 1.05rem;
  font-weight: 600;
}

.summary-card .label {
  color: #9ca3af;
}

body.light-theme .summary-card .label {
  color: #6b7280;
}

.summary-card .positive {
  color: #22c55e;
}

.summary-card .negative {
  color: #ef4444;
}

.placeholder {
  color: #6b7280;
  font-size: 0.9rem;
  text-align: left;
}

.insight-box {
  margin-top: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px dashed #4b5563;
  font-size: 0.82rem;
  color: #d1d5db;
}

body.light-theme .insight-box {
  border-color: #d1d5db;
  color: #374151;
}

.table-wrapper {
  max-height: 360px;
  overflow: auto;
  border-radius: 0.5rem;
  border: 1px solid #1f2937;
}

body.light-theme .table-wrapper {
  border-color: #e5e7eb;
}

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

thead {
  position: sticky;
  top: 0;
  background-color: #020617;
  z-index: 1;
}

body.light-theme thead {
  background-color: #f9fafb;
}

th,
td {
  padding: 0.4rem 0.6rem;
  text-align: right;
  border-bottom: 1px solid #111827;
}

body.light-theme th,
body.light-theme td {
  border-bottom-color: #e5e7eb;
}

th:first-child,
td:first-child {
  text-align: left;
}

tbody tr:nth-child(even) {
  background-color: rgba(15, 23, 42, 0.7);
}

body.light-theme tbody tr:nth-child(even) {
  background-color: #f9fafb;
}

tbody tr:hover {
  background-color: rgba(31, 41, 55, 0.9);
}

body.light-theme tbody tr:hover {
  background-color: #e5e7eb;
}

.value-positive {
  color: #22c55e;
}

.value-negative {
  color: #ef4444;
}

.table-actions {
  margin-top: 0.6rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chart-wrapper {
  position: relative;
  width: 100%;
  height: 260px;
}

.chart-controls {
  margin-top: 0.6rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
}

.info-card {
  margin-top: 0.25rem;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.8rem 1.2rem;
  font-size: 0.9rem;
}

.info-grid h3 {
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
}

.info-grid p {
  margin: 0.1rem 0;
}

.info-grid ul {
  margin: 0.1rem 0 0.2rem 1.1rem;
  padding: 0;
}

footer {
  margin-top: 1.5rem;
  text-align: center;
  color: #6b7280;
  font-size: 0.8rem;
}

body.light-theme footer {
  color: #9ca3af;
}

@media (max-width: 600px) {
  .app-container {
    padding: 1rem;
  }

  .header-main {
    flex-direction: column;
    align-items: flex-start;
  }

  .chart-wrapper {
    height: 220px;
  }
}

@media print {
  body {
    background-color: #ffffff;
  }
  .app-container {
    max-width: 100%;
    padding: 0.5rem;
    color: #111827;
  }
  .card {
    background: #ffffff;
    border-color: #e5e7eb;
    box-shadow: none;
  }
  .theme-toggle,
  .sticky-actions,
  .chart-controls,
  .table-actions,
  .summary-actions {
    display: none !important;
  }
}
