:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  background: #f6f7f9;
  color: #1d252c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
}

button,
input,
select {
  font: inherit;
}

.app-header {
  align-items: center;
  background: #ffffff;
  border-bottom: 1px solid #d9e0e7;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 18px max(16px, calc((100vw - 1120px) / 2));
  position: sticky;
  top: 0;
  z-index: 2;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  font-weight: 750;
}

h2 {
  font-size: 17px;
  font-weight: 700;
}

.app-header p {
  color: #5d6b78;
  font-size: 13px;
  margin-top: 3px;
}

.app-shell {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) 320px;
  margin: 0 auto;
  max-width: 1120px;
  padding: 16px;
}

.input-panel,
.auth-panel,
.chart-panel,
.table-panel {
  background: #ffffff;
  border: 1px solid #d9e0e7;
  border-radius: 8px;
  padding: 16px;
}

.input-panel,
.chart-panel,
.table-panel {
  grid-column: 1 / 2;
}

.auth-panel {
  grid-column: 2 / 3;
  grid-row: 1 / 2;
}

.chart-panel {
  min-height: 400px;
}

.field-row {
  display: grid;
  gap: 12px;
  grid-template-columns: 92px repeat(3, minmax(120px, 1fr));
  margin-top: 14px;
}

label {
  color: #34414d;
  display: grid;
  font-size: 13px;
  gap: 6px;
}

input,
select {
  background: #ffffff;
  border: 1px solid #b9c5d0;
  border-radius: 6px;
  color: #17202a;
  min-height: 42px;
  padding: 8px 10px;
  width: 100%;
}

input:focus,
select:focus,
button:focus {
  outline: 3px solid #b8d7ff;
  outline-offset: 1px;
}

.form-actions {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-top: 14px;
}

output {
  color: #1f3b57;
  font-weight: 700;
}

button {
  background: #176b87;
  border: 0;
  border-radius: 6px;
  color: #ffffff;
  cursor: pointer;
  font-weight: 700;
  min-height: 42px;
  padding: 9px 16px;
}

button:hover {
  background: #12566d;
}

.auth-panel form {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.year-picker {
  align-items: center;
  display: flex;
  gap: 8px;
  min-width: 132px;
}

.section-title {
  align-items: start;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  margin-bottom: 10px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  justify-content: end;
}

.legend span {
  align-items: center;
  color: #4c5a66;
  display: inline-flex;
  font-size: 12px;
  gap: 5px;
}

.legend i {
  border-radius: 3px;
  display: inline-block;
  height: 10px;
  width: 10px;
}

.buy {
  background: #2f7dbd;
}

.sell {
  background: #d18b2c;
}

.water {
  background: #2f9d7e;
}

.total {
  background: #c53f5c;
}

canvas {
  display: block;
  height: 320px;
  width: 100%;
}

.table-wrap {
  margin-top: 12px;
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  font-size: 14px;
  min-width: 620px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid #e3e8ed;
  padding: 10px 8px;
  text-align: right;
  white-space: nowrap;
}

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

th {
  color: #53616e;
  font-size: 12px;
  font-weight: 700;
}

@media (max-width: 860px) {
  .app-header {
    align-items: stretch;
    flex-direction: column;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .input-panel,
  .auth-panel,
  .chart-panel,
  .table-panel {
    grid-column: 1 / 2;
  }

  .auth-panel {
    grid-row: auto;
  }

  .field-row {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 12px;
  }

  .input-panel,
  .auth-panel,
  .chart-panel,
  .table-panel {
    padding: 14px;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .form-actions,
  .section-title {
    align-items: stretch;
    flex-direction: column;
  }

  .legend {
    justify-content: start;
  }
}
